Ralph Schindler wrote:
Hey group,
I am curious how everyone implements common headers and footers within
a given application. As I see it there are two methods:
a) include the header and footer in each view script via the
$this->render(..) routine.
I simply within the main site view call in the following files:
<?php echo $this->render('../themes/' . $this->theme_template .
'/html/html_head.inc.php') ?>
echo $this->render($this->actionTemplate);
This allows the view to specify the template and the template elements
are called via the theme.
b) use Zend_Controller Plugins to write to the view a standard header
and footer to the view body at preDispatch() postDispatch() /
preRouteStartup / postRouteStartup times.
Both methods have their pros and cons..
In method a) you are required to handle it in every script, which can be
tedious. But it allows you flexibility to not include the common header
and footer blanketly on all requests when it makes sense not to include it.
Method b) writes headers and footers on all requests, unless I am
missing something. The benefit is that you can write specific
controller/action scripts and they can be completely autonomous from the
rest of the application.
I like method b), but I wonder: Are there ways to inject (or callback)
to write specific controller/action needed headers to the common header,
for example, adding a page specific JS script to a pages <head>. Are
there ways that a specific controller/action can choose not to use a
header/footer dispatched previously?
Looking for best practices / ideas here..
Thanks,
Ralph