2008年12月8日星期一

Re: [fw-mvc] Using HeadLink from a view helper (in the layout)

Thanks Matthew.

The only problem with this is that there is no way of ensuring that a user
of the view helper will place it correctly.

Glen.


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.

没有评论: