Search code examples
model-view-controllerzend-frameworklayoutcontrollerzend-framework-mvc

In Zend MVC, how do you pass a variable set int the controller, to a layout?


I have to pass the page title names and meta information to the layout but not to sure how to do this =/


Solution

  • You may set you page titles and other info in your controller (if you're planning to change these depending on the action called):

    $this->view->headTitle('123');
    $this->view->headMeta('text/html; charset=UTF-8', 'Content-Type', 'http-equiv');
    

    And then render them in your layout:

    echo $this->headTitle() . $this->headMeta();