Zend_Layout: $this->content not found from within layout page

I tried to use Zend_Layout to wrap page content into … a layout!

At first I struggled a bit because when I tried to echo ‘$this->content’, no data got printed.

In fact, as explained in official doc (but hardly understandable for me), when your layout page gets rendered, it’s rendered by a view object, not by a layout object.

Therefore, you need to access the layout object through ‘layout()’ method of view object.
=> to output your rendered content, do NOT call

echo $this->content;

but rather

echo $this->layout()->content;

sources

Leave a Reply