I am new to zendframework . I am trying to implement two step view lay out:
Bootstrap.php(view/Bootstrap.php)
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function _initRoutes()
{
$options = array(
'layout' => 'layout',
'layoutPath' => '/layout/layout.phtml',);
$layout = Zend_Layout::startMvc($options);
}
}?>
layout.phtml(application/view/scripts/layout/layout.phtml)
<?php
include "header.php";
?>
// view contents goes here.
<?php
$this->layout()->content;
?>
// footer goes here.
<?php
include "footer.phtml";
?>
i am a absolute beginner step by step explanation is more appreciated .Thanks.
The easiest way to enable layouts is to run the Zend_Tool command from the command line
zf enable layout, this will add the lineresources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"to your application.ini and build the directory for the layout and the default file
layout.phtml.Alternatively you can specify your layout path and default layout name with 2 lines in your application.ini file:
other layout/view options may be set in your application.ini to be callled in your view:
then in your bootstrap.php you can call on these resources to initialize your view:
I also included a convenience method _initRegistry() to make config options available everywhere with minimal code.
The layout in ZF is a simple html page with placeholder added for dynamic or configured options:
Hope this helps.