Pages

Sunday 1 July 2012

zend layout

A website have different pages but have a page where all the footer/header/left/right section is included know as template/layout. Each page is called from that layout. A site may have one or more layout depend on website.


  • Automate selection and rendering of layouts.
  • Provide different scope for layout related variables and content.eg render(), partial().
  • Allow configuration, including layout name, layout script resolution (inflection), and layout.
  • You can disable layouts, changing layout scripts, and other states; allow these actions from within action controllers and view scripts.
  • Follow same script resolution rules (inflection) as the ViewRenderer. 
There are different options to set the options for layout.

//static method
Zend_Layout::startMvc($optionArray)
Zend_Layout::startMvc($optionIniObject)

//constructor
$layout = Zend_Layout($optionArray);
$layout = Zend_Layout($optionIniObject);

//methods
$layout = Zend_Layout();
$layout->setOptions($optionArray);
$layout->setOptions($optionIniObject);

//using accessors
$ayout->setLayout('layout)
->setLayoutPath('/views/layouts/mylayout.phtml');


You can use Zend_Layout as an standalone component but in that case all full features will not available. following are available.
Scoping of layout.
isolation of layout view scripts from another view scripts.

No comments:

Post a Comment

Please add comments only related to zend framework certification.