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> <!-- enter our head tag --> <head> <!-- we want to output in UTF-8 --> <meta charset="utf-8"> <!-- let's use the headTitle View Helper to output our website title --> ...