The other day I was pointed at

http://akrabat.com/zend-framework-tutorial/

Look on page 9. It seems to talk about rendering header and footers, but I would think that you can also render other common aspects using this method as well.

James


On May 29, 2007, at 11:43 AM, Kevin McArthur wrote:

Surely, nested templates will have some sort of built-in basic functionality. I dont know many PHP developers who use templates like they're a series of concatenated strings. It just doesn't jive with the nested nature of html.

Most PHP apps follow a standard/shared layout approach; so whats the 'framework' way of handling common elements now? render header, content, footer?

Kevin
----- Original Message ----- From: "Rob Allen" <[EMAIL PROTECTED]>
To: <fw-general@lists.zend.com>
Sent: Tuesday, May 29, 2007 2:09 AM
Subject: Re: [fw-general] ViewRenderer and nested templates


Kevin McArthur wrote:
Hi Guys,

I'm trying to upgrade several sites to 1.0 but my sites tend to use a main template (engine.tpl) plus a set of sub templates (actionName.tpl) (menu.tpl) etc... it seems fairly evident how to sub-render, but with outer most template always being the same file, how do you set this with the view renderer's automatic actions to set the $view->content variable
to the actionName template automatically.



Currently, I'm exploring extending ViewRender's renderScript() to do
something similar.

My first attempt looks like this:

class My_Controller_Action_Helper_ViewRenderer
extends Zend_Controller_Action_Helper_ViewRenderer
{
   public function renderScript($script, $name = null)
   {
       if (null === $name) {
           $name = $this->getResponseSegment();
       }
       $content = $this->view->render($script);

       $this->view->content = $content;

       $layoutTemplate = 'site.tpl.php';
       $this->getResponse()->appendBody(
           $this->view->render($layoutTemplate),
           $name
       );

       $this->setNoRender();
   }
}


I also have:

   $viewRenderer = new My_Controller_Action_Helper_ViewRenderer();
   $viewRenderer->setViewSuffix('tpl.php');
   Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

in my bootstrap before I first instantiate the front controller, so that
my ViewRenderer is used.




Regards,

Rob...


Reply via email to