News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Master Zend Framework:
Change Layout in Controllers and Actions in Zend Framework 2
June 27, 2014 @ 10:07:20

Matthew Setter has a new post to his Master Zend Framework site today showing you how to change layouts in controllers and actions for a Zend Framework v2 based application.

In Zend Framework 2, if you want to change the layout just for one action or for every action in a controller, how do you do it? How do you do it without overriding the layout for every action throughout the entire application? In today's post, based on an excerpt from Zend Framework 2 for Beginners, we see how to achieve both of these requirements.

He talks about the framework's use of the two-step view pattern and what the "template_map" definition usually looks like in a default ZF2 application. He shows three different ways to do the view switching from the controller or action:

  • Override the default layout in your module
  • Override the layout per/action
  • Override the layout per/controller

Each of these comes with a bit of code showing you how to make it work. They move from simplest to more complex, with the layout per controller being the most complex. It's not that it's difficult, it's just that there's more involved to make it work. You can either do it at the controller level or at the module level.

0 comments voice your opinion now!
tutorial zendframework2 controller action change ayout

Link: http://www.masterzendframework.com/views/change-layout-controllers-actions-zend-framework-2

blog comments powered by Disqus

Similar Posts

Christoph Dorn's Blog: Profiling queries with Zend_Db_Profiler_Firebug

SearchOpenSource.com: Automating Amazon research with the Zend Framework

DevShed: Creating a Simple Threaded Discussion Forum

WeberDev.com: PHP 101 (part 14): Going To The Polls

BillS' IIS Blog: How to install PHP on IIS7 (RC1)


Community Events





Don't see your event here?
Let us know!


voicesoftheelephpant framework composer symfony series community artisanfiles language podcast interview list tool security library opinion release laravel introduction conference version

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework