« Return to Thread: Controller and View Question

Controller and View Question

by Ralph Schindler :: Rate this Message:

Reply to Author | View in Thread

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.

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

 « Return to Thread: Controller and View Question