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

Create a Layout Script

Now that you have your configuration in place, you need to create your layout script. First, make sure that you've created the "application/layouts/scripts" directory; then, open an editor, and create the markup for your layout. Layout scripts are simply view scripts, with some slight differences.

    <title>My Site</title>
    <?php echo $this->layout()->content ?>

In the example above, you'll note the call to a layout() view helper. When you register the Zend_Layout resource, you also gain access to both an action and view helper that allow you access to the Zend_Layout instance; you can then call operations on the layout object. In this case, we're retrieving a named variable, $content, and echoing it. By default, the $content variable is populated for you from the application view script rendered. Otherwise, anything you'd normally do in a view script is perfectly valid -- call any helpers or view methods you desire.

At this point, you have a working layout script, and your application is informed of its location and knows to render it.

Zend Framework