How to change the layout template in Zend Framework 2.5

Hi guys! In this tutorial I will explain how to change the the layout template in Zend Framework 2.5.

Open the module.config.php file and add this code

'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
),

in

'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
// here
),

If you want to change the layout ony for a page, add

'layout/layoutname' => __DIR__ . '/../view/layout/layout.phtml',

and in your Controller's action add:

$this->layout('layout/layoutname');

You can also create only a blank page layout and create a customized template for each page from the view files.

Video tutorial:









Leave a Comment