The layout should really be the last thing that gets rendered, immediately before the response is sent.

Thus, as your templates go around adding to head* helpers... the layout parses after those actions do and the resulting containers are already full when the echo is encountered in the layout.

Make sense?

Kevin McArthur

bfoust wrote:
The headScript() and headLink() helpers are purportedly used to collect
additions throughout the page-building process, then output the results as a
group.



 You may specify a new script tag at any time. As noted above, these may
be links to outside resource files or scripts theselves.

<?php // adding scripts
$this->headScript()->appendFile('/js/prototype.js')
                   ->appendScript($onloadScript);
?>


So you'd think by the description in the manual and by the name of the
helper, that it's doing something special to inject the results into the
header of the output.

But I see no evidence of that after attempting to use it. These "head"
helpers are nothing of the sort. They're only containers that get echoed to
the output stream as soon as the reference is encountered:

    <?= $this->headScript() ?>
    <?= $this->headLink() ?>

How is that useful? The calls to $this->headScript()->prependXXX() are
processed later in the .phtml file, so that content never gets rendered?

If this mechanism worked as expected, all the calls to these headXXX helpers
in all views of the layout would be collected and automatically injected
into the <head> section upon completion of the output, but before being sent
to the client.

No special code would be needed in the application's layout or view to
output it (which just breaks the mechanism, as we have seen, because the
*current* contents of the headXXX helper get output, rather than the
*future* contents as expected).

What am I missing? Is there an easy way to tweak ZF to get the expected
behavior?


--

Kevin McArthur

StormTide Digital Studios Inc.
Author of the recently published book, "Pro PHP"
http://www.stormtide.ca

Reply via email to