PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

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:

<?php
$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
echo $layout->render();

Zend Framework