ZF-8013: Nested layouts, in Zend_Layout

Issue Type: New Feature Created: 2009-10-04T09:54:16.000+0000 Last Updated: 2011-01-27T23:44:34.000+0000 Status: Open Fix version(s): Reporter: David Reuss (davidreuss) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Layout

Related issues: Attachments: - zend_layout_nested_layouts_patch.diff


Nested layouts in Zend_Layout would be really useful. Sometimes you have a page that's split in multiple larger segments, where you would need several layouts, to get it right.

I've recently needed it in a project, and i didn't come up with a nice solution using helpers/actions etc.

It's also useful if you just want your current view wrapped in some plain HTML.

I've looked elsewhere, and Symfony templating has this feature, implemented really well, and simple.… (Under "Inheritance"). I believe django has this as well, with their templating solution, and ZF would benefit from it as well.

Usage is something like:

<pre class="highlight">

<?php $this->layout()->extend('wrapper') ?>

This is my view wrapped by a layout.

<pre class="highlight">

    <?= $this->layout()->content ?>

Expected result

<pre class="highlight">

    This is my view wrapped by a layout.

I've attached a really simple patch that implements the functionality. It's basically just the same strategy as the symfony templating solution uses, and in my view it fits quite nicely with Zend_Layout, and actually i'm a bit surprised this hasn't been thought of before. Unless i'm missing some proper way of doing this.

My patch - (Basically a port of symfonys strategy) can be found here:

I couldn't find anything in the license that prevents this from going into ZF but maybe i'm wrong. According to the templating web-page, it's released under the MIT license.

Raw version is attached.


Posted by David Reuss (davidreuss) on 2009-10-04T10:10:18.000+0000

Patch to provide nested layouts for Zend_Layout

Posted by Max Gordon (mgordon) on 2011-01-27T23:44:31.000+0000

This issue might also enable a good solution to the problem with Dojo widgets being created after the echo $this->dojo();, see Stackoverflow zend-dojo-form-in-a-layout and Stackoverflow zend-dojo-form-not-rendering-in-layout that have problems when they can't nest a layout containing all the Dojo code into the main layout. I've also asked the docs to be clarify on this point. Adding this functionality would probably be the most elegant way for getting Dojo widgets into the layout.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.