(on Monday, 08 December 2008, 09:18 AM -0800):
> The only problem with this is that there is no way of ensuring that a user
> of the view helper will place it correctly.
Well, that becomes an education issue, then. The fact of the matter is
that the layout script is evaluated sequentially, just as any other view
script. So, calls to an aggregator that occur after the aggregator has
been rendered will have no effect.
> Matthew Weier O'Phinney-3 wrote:
> >
> > -- Dodger <glen.84@gmail.com> wrote
> > (on Monday, 08 December 2008, 02:07 AM -0800):
> >> I have a view helper that is used in my layout file, which (among other
> >> things) adds CSS to the document head using the HeadLink helper. The
> >> problem
> >> is that the helper is using HeadLink *after* the layout calls "echo
> >> $this->headLink();", so the CSS is never output.
> >>
> >> Is there no way of adding CSS to the head from within a layout file
> >> (after
> >> the document head)?
> >>
> >> I would have liked to have avoided CSS in the body.
> >
> > Capture the return value of your view helper at the top of your layout
> > script, and then echo it within the body:
> >
> > <? $foobar = $this->myHelper(); ?>
> > <?= $this->doctype() ?>
> > <html>
> > <head>
> > <?= $this->headTitle() ?>
> > <?= $this->headLink() ?>
> > </head>
> > <body>
> > <?= $this->layout()->content ?>
> > <?= $foobar ?>
> > </body>
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect | matthew@zend.com
> > Zend Framework | http://framework.zend.com/
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Using-HeadLink-from-a-view-helper-%28in-the-layout%29-tp20892525p20899535.html
> Sent from the Zend MVC mailing list archive at Nabble.com.
>
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论