Using Zend_Layout as a Standalone Component
As a standalone component, Zend_Layout does not offer nearly as many features or as much convenience as when used with the MVC. However, it still has two chief benefits:
-
Scoping of layout variables.
-
Isolation of layout view script from other view scripts.
When used as a standalone component, simply instantiate the layout object, use the various accessors to set state, set variables as object properties, and render the layout:
-
$layout = new Zend_Layout();
-
-
// Set a layout script path:
-
$layout->setLayoutPath('/path/to/layouts');
-
-
// set some variables:
-
$layout->content = $content;
-
$layout->nav = $nav;
-
-
// choose a different layout script:
-
$layout->setLayout('foo');
-
-
// render final layout