Monday, 7 April 2014

Layout Controllers

To simplify your frontend controllers, we have created a new class \Cubex\Views\LayoutController.

If you change your controllers to extend this class, any scalar or renderable responses from your controller action (or echo output with a null response), will be inserted into the default layout under the 'content' section.

If you want to change the default content area for your responses to be nested, you can set the protected property _contentName e.g.
protected $_contentName = 'newcontentarea';

By default, a new layout object will be created based on your controller.  This will pull back Default.phtml from a Layouts folder in the level above the folder holding your controllers.  You can set your own layout by simply calling $controller->setLayout(Layout);