point I was thinking how odd it was that the view helpers could be
used in the layout AFTER $view->dojo() had been echo'd, and still
properly require the necessary dijits at a later point in time. The
answer is, of course, they can't. Unless...you use an instance of
Zend_TimeTravel. Ah, but how would you code around the ensuing
paradoxes? ;)
Thanks for showing me how to use the helpers with the layout and
achieve the functionality I was looking for. As always, much
appreciated.
--regards,
Nathan Garlington
On Fri, Feb 26, 2010 at 6:16 AM, Matthew Weier O'Phinney
<matthew@zend.com> wrote:
> -- Nathan Garlington <garlinto@gmail.com> wrote
> (on Thursday, 25 February 2010, 02:58 PM -0700):
>> V1.10.1
>>
>> I have been refactoring my layouts and views to use the dojo view
>> helpers, thinking that the helpers auto-required their respective
>> dijits ala Zend_Dojo_Form, and quickly found out that this is not the
>> case. Am I missing a step in configuring the view (other than
>> dojoRequire-ing the dijits myself) that will enable this
>> functionality, or is this a functionality that doesn't exist atm?
>
> The functionality does exist (has since it was initially released), and
> it does create the necessary dojo.require statements.
>
> Please be aware, though, that if you are adding dijits to your _layout_,
> you will need to be careful about the order in which you do so. Any
> dijits created _after_ the dojo view helper has been echoed will not be
> present.
>
> As an example:
>
> <html>
> <head>
> <?php echo $this->dojo() ?>
> </head>
> <body>
> <?php $this->tabContainer()->captureStart('tabs') ?>
> <?php $this->contentPane()->captureStart('main') ?>
> <?php echo $this->layout()->content ?>
> <?php echo $this->contentPane()->captureEnd('main') ?>
> <?php echo $this->tabContainer()->captureEnd('tabs') ?>
> </body>
> </html>
>
> In the above, the tab container and content pane should be aggregating
> dojo.require statements for dijit.layout.TabContainer and
> dijit.layout.ContentPane, respectively -- but since the dojo() view
> helper was rendered _earlier_ in the script, they will not have been
> aggregated yet when that happens.
>
> The solution to this is to move these calls into another view script,
> capture that content early in your layoute, and then echo it later.
>
> content.phtml:
> <?php $this->tabContainer()->captureStart('tabs') ?>
> <?php $this->contentPane()->captureStart('main') ?>
> <?php echo $this->layout()->content ?>
> <?php echo $this->contentPane()->captureEnd('main') ?>
> <?php echo $this->tabContainer()->captureEnd('tabs') ?>
>
> layout.phtml:
> <?php $content = $this->render('content.phtml') ?>
> <html>
> <head>
> <?php echo $this->dojo() ?>
> </head>
> <body>
> <?php echo $content ?>
> </body>
> </html>
>
> --
> Matthew Weier O'Phinney
> Project Lead | matthew@zend.com
> Zend Framework | http://framework.zend.com/
> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
>
没有评论:
发表评论