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 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"> ...

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