> 
> I'm just playing with Zend_Layout and have a quick question. What I'd  
> like to do is have a three part view. I'd like my designer to design a  
> wrapper "template" that consists of the markup surrounding the output  
> of action views. This is exactly what Zend_Layout does so perfect! but  
> if possible I'd like the designer templates to exclude the doctype,  
> head and <html> and <body> tag stuff and stick strictly to what comes  
> after <body>.  That way designers don't need to worry about the non-
> design stuff.
> 
> doc.phtml:
> 
> <!DOCTYPE html
>      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html>
> <head>
>      <meta http-equiv="Content-Type" content="text/html;  
> charset=utf-8" />
>      <title><?= $this->headTitle() ?></title>
>      <?= $this->headScript() ?>
>      <?= $this->headStyle() ?>
> </head>
> <body>
>     <?= $this->layout()->content ?>
> </body>
> </html>
> 
> which includes the following designer layout.phtml in "content":
> 
> <div id="content">
>         <!-- renders /nav/menu -->
>         <div id="nav"><?= $this->layout()->nav ?></div>
>         <!-- renders /foo/index + /comment/fetch -->
>         <div id="content"><?= $this->layout()->content ?></div>
> </div>
> 
> which includes the action.phtml template in "content". 
> 


You could probably create a view helper like this:

class My_View_Helper_NestedLayout
{       
  
    public function nestedLayout($layoutName)
    {
        try {                                     
                $layout = Zend_Layout::getMvcInstance();                        
                        
                echo $layout->render($layoutName);                
            }
        } catch (Zend_Exception $e) {
            $this->view->layout($layoutName);
        }
    }           

    public function setView(Zend_View_Interface $view)
    {
        $this->view = $view;
    }
}

add the helper path (see
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.custom)

Usage in your main layout (doc.phtml):

...
<?  $this->nestedLayout('content/layout') ?>   
...

this would render the layout file 'content/layout.phtml' (relative to your
layout path) at the position where like to render the content.


Please correct me if this might fail in any case!
-- 
View this message in context: 
http://www.nabble.com/Zend_Layout-with-nested-layout--tp15878224s16154p15912857.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to