views:

55

answers:

2

I use a basic setup which uses a layout.phtml for the HTML Layout and view scripts for the content part.

I want to control some variables in the layout in my controllers, i.e. the title of my site.

How can I access my layout to output variables from within the controller?

Thanks for your feedback!

A: 
$myLayout = Zend_Layout::getMvcInstance()->getView();
$myLayout->var = 'foo:bar';

in layout.phtml:

echo $this->layout()->var;
ArneRie
does not work, put the first one in my a controllers action and the second one in the layout.phtml without any changes
favo
+1  A: 

Anything you assign to view in your controllers will be accessible both in view scripts and layout scripts - they use the same Zend_View.

As for setting the title of the page, simply use the HeadTitle view helper http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headtitle

robertbasic
thank you, looks i'm not thinking "easy" enough :-)
favo