ZF-8013: Nested layouts, in Zend_Layout
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. http://components.symfony-project.org/templating/… (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:
<?php $this->layout()->extend('wrapper') ?> This is my view wrapped by a layout.
<?= $this->layout()->content ?>
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: http://gist.github.com/201465
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.