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...