I use the layout in my application but do have times where I need to change
or disable it.

To disable the layout in a controller this works,

Zend_Layout::getMvcInstance()->disableLayout();

To change the layout from in any controller without a lot of code changes.

// can adjust the layout path using 
Zend_Layout::getMvcInstance()->setLayoutPath('new-path-here');

// will use the layout path setting (loads account_base_page.phtml)
Zend_Layout::getMvcInstance()->setLayout('account_base_page');

// assign var to layout directly
Zend_Layout::getMvcInstance()->assign('title', 'this is a title');

To display the title var in the layout template, use the following:

echo $this->layout()->title;

Terre
 

________________________________

From: Peter Warnock [mailto:petewarn...@gmail.com] 
Sent: Saturday, September 05, 2009 12:51 PM
To: Matthew Lurz
Cc: fw-general@lists.zend.com
Subject: Re: [fw-general] Using Zend Layout for module not main application


In a 1-off scenario, I prefer method 3. No config necessary.


Zend_Layout::startMvc();
$this->_helper->layout->setLayout('foobaz');

 - pw


On Fri, Sep 4, 2009 at 10:02 AM, Matthew Lurz <mlur...@gmail.com> wrote:



        A couple of additional ways...
        
        3) Add the layout setup code to the controller init method.
        
        4) If you find yourself having to do the above a lot, create an
action
        helper with the layout setup code which you would then call in the
        controller init method or wherever you need it.
        
        Just wanted to throw those out there though if it were me I think I
would
        prefer 1 or 2. The ZF is very flexible and will bend to your will!!
        


        sagittariidae wrote:
        >
        > Is it possible to have Zend Layout work only for a module whilst
the main
        > application does not use Zend Layout?
        >
        > The problem I am facing is that an already existing application
that uses
        > Zend Layout now needs to reside as a module in another application
that
        > does not use Zend Layout and instead uses a Zend View/Smarty
hybrid.
        >
        > If it is possible would I need to set it up in the main
application config
        > (.ini) file or would i need to use a module specific config file?
        >
        > Any help would be much appreciated.
        >
        
        --
        
        View this message in context:
http://www.nabble.com/Using-Zend-Layout-for-module-not-main-application-tp25
291667p25298169.html
        
        Sent from the Zend Framework mailing list archive at Nabble.com.
        
        



Reply via email to