Zend Layouts for Default and Admin

View: New views
3 Messages — Rating Filter:   Alert me  

Zend Layouts for Default and Admin

by Opel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have set up my app directory as follows :

application
---- modules
---- templates
---------default
---------admin
---- models
library


What I am trying to do is use default template for my public view and admin template for the admin module. I need to set my bootstrap up to switch the template for that single "admin" module. This was covered in Padraic Brady's tutorial but seems to have been taken down and I didn't have a copy of the source.

Could anyone advice me how to do this. The searches on forum for answers all seem to be different layouts per module.

Re: Zend Layouts for Default and Admin

by Timo Ziemann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You could register a plugin which sets the alternative layout if the module is == admin...

For example:
if($request->getModuleName() == 'admin')
    Zend_Layout::getMvcInstance()->setLayout('alternative');

Opel wrote:
I have set up my app directory as follows :

application
---- modules
---- templates
---------default
---------admin
---- models
library


What I am trying to do is use default template for my public view and admin template for the admin module. I need to set my bootstrap up to switch the template for that single "admin" module. This was covered in Padraic Brady's tutorial but seems to have been taken down and I didn't have a copy of the source.

Could anyone advice me how to do this. The searches on forum for answers all seem to be different layouts per module.

Re: Zend Layouts for Default and Admin

by Matthew Lurz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In case you are still looking for a solution:

class My_Layout_Controller_Plugin_Layout extends Zend_Layout_Controller_Plugin_Layout
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $module = $request->getModuleName();
        if ('admin' == $module) {
          $this->getLayout()->setLayout($module);
        }
    }
}

Opel wrote:
I have set up my app directory as follows :

application
---- modules
---- templates
---------default
---------admin
---- models
library


What I am trying to do is use default template for my public view and admin template for the admin module. I need to set my bootstrap up to switch the template for that single "admin" module. This was covered in Padraic Brady's tutorial but seems to have been taken down and I didn't have a copy of the source.

Could anyone advice me how to do this. The searches on forum for answers all seem to be different layouts per module.