dmitrybelyakov wrote:
Hi,

Today i came across an issue that i couldn’t find a nice solution for. In
short it stated in the subject, placeholder view helpers like headScript()
don’t work for partials (or any custom view helpers) when in layout context.

Like in this example:

<?
    //layout phtml
    <head>
        <?=$this->headLink(); ?>
    </head>

    <body>
        <?=$this->partial('blogposts.phtml')?
    </body>

    ...

    //partial.phtml
    <?php $this->headLink()->appendStylesheet('partial.css')>
?>

So this will not work for the obvious reason - the partial is executed after
the placeholder aggregator, so anything appended in the partial view will
never get to the head.

After some research i see it’s a well-known issue that many people
encounter.
So my question is - will this issue be addressed in the future versions?

Because all the methods like the one described in this thread:

http://www.nabble.com/Using-HeadLink-from-a-view-helper-(in-the-layout)-tt20892525.html

just seem ... well... not very ‘clean’.

Also maybe there’s a known solution that i can use in front controller
plugin (for example) that will take care of the issue, or any other approach
how this may be implemented.

Thanks in advance and good luck.
Dmitry.

I would say that is not using the paradigm in the way it was intended. Either call the partial in the view, or if the the partial is meant to be the layout of everything, put it directly in the layout.phtml. Layout is the final assembling point for all the other sections. If you have already echo'ed a section into its place then you can't add anymore to the section and expect it to update the already output code.


Reply via email to