Zend Framework 2 layout.phtml -
so, can write code in controller affect view... code layout.phtml read from? (i assuming module.php, i'd feedback)
edit: clear... in controller, can variable equal , access in view. i'd discover similar action inside layout.
thanks
you ask various questions in single post. try address few of them.
how layout work?
in zend framework 2 there concept of "view models". view model object has couple of variables , template assigned. template rendered given variables.
furthermore, can nest view models. 1 view model (the "layout") has child created controller. child rendered , stored variable in parent view model. name of variable called "capture to".
what happens, have controller , view model created. view model inserted child view model in new model, layout. child set "capture to" of content
. in layout, result of child view model inserted in $content
variable.
how access layout variables in controller?
there a layout
controller plugin gives direct access layout view model. can set variables directly there:
public function indexaction() { $this->layout()->setvariable('foo', 'bar'); }
then $foo
echos bar
in layout.
how access layout variables in view script?
there a layout
view helper gives direct access layout view model. can set variables there too:
<?php $this->layout()->foo = 'bar';?>
then $foo
echos bar
in layout.
Comments
Post a Comment