O'Reilly logo

Zend Framework 2 Cookbook by Josephus Callaars

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a global layout template

The view scripts can be very dynamic but most of the time we need a global template that we want to wrap around the output from our Action view scripts. This recipe will explain exactly how to do that, and also tells us how that would work.

Getting ready

For this recipe a working Zend Framework 2 skeleton application is needed as we will do some creating and editing of some files which are used in there.

How to do it…

The following is how we set about achieving this:

Creating the main layout file

Let's now create the main file /module/Application/view/layout/layout.phtml we use to create our layout:

<!-- first of all we want to output the doctype --> <?php echo $this->doctype(); ?> <!-- now we add the HTML tag --> <html> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required