-- Serg B <[EMAIL PROTECTED]> wrote
(on Sunday, 06 January 2008, 02:11 PM +1100):
> Is there a set way to render a multi-part template with Zend Framework
> (I am using version 1.0.3)?
> 
> For example: I have an action that renders script: search.phtml.
> Search.phtml consists of data specific to search action and lots of
> common code such as toolbar, header and footer... Simplistic thinking
> would be to just call an "include" from inside the phtml script and
> include the header and so on. However I wanted to know if there is
> something more efficient/a better way of doing this? Especially when
> it comes to populating the variables inside (all of the) the phtml
> templates.
> 
> For example, can I do:
> 
> $this->render('globals/header.phtml');
> $this->render();
> $this->render('globals/footer.phtml');
> 
> 
> I am not sure what HTTP headers are being sent each time I call render
> so I don't really want to risk it by calling it multiple times. 

No worries there. render() sends no headers, and the dispatcher buffers
all output, adding it to the response object; no headers are sent in the
MVC until all actions are completed.

> Also since I am using 1.0.x branc Zend_Layout component is not really
> an option (unless I am missing something).

You can do as you note above without an issue. However, it's not a great
way to do things; if you later decide to use Zend_Layout or another Two
Step View solution, you'll end up needing to edit all your view scripts
to strip out those calls to render the headers and footers.

You may want to look on the list archives at nabble.com and search for
'TwoStep' or 'Two Step'; I've posted sample plugins in the past that can
be used for implementing Two Step Views with the Zend_Controller MVC.

Alternately, consider using a nightly snapshot or a current SVN revision
and giving Zend_Layout a try; it's stable and tested at this point, and
will be in the next release.

> Any links to online documentation, help and advice on how to correctly
> render multi-part templates from an action method would be very
> appreciated.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to