Creating reusable Views
In this time of dynamic applications we have widgets or content that can be used more than once. Instead of getting everything at the same time we want to be able to dynamically load new objects in, or at least not have to do a lot to get functionality working.
Getting ready
For this recipe we need nothing more than a working Zend Framework 2 skeleton application.
How to do it…
In this recipe we'll be discussing how to create reusable templates and the best way of using them in an application.
Use the Action view helper to get the re-usable content
The Action
view helper is a great way of calling different actions in our code to retrieve other parts of our application:
<div class="left">Some content on the left!</div> <div class="right"> <?php echo $this->action( // The action to call 'sidebar', // The controller to call 'templates', // The module to call 'application', // Parameters to parse along...