Basic flow of pages in Zend Framework PHP -


how zend link $this->layout()->content scripts/index/index.phtml?

i think i'm failing understand basics of how pages supposed stick together. i've looked @ quick start on zend site it's far simplistic.

so tomáš fejfar explained that's how $this->layout()->content works. yet interesting 'content' not variable in layout. in fact, 'content' key in view placeholder called 'zend_layout'. reason, following snippets equivalent echo $this->layout()->content in layout.phtml:

 $placeholder = zend_view_helper_placeholder_registry::getregistry()->getcontainer('zend_layout');  echo $placeholder['content'];   // or   echo $this->placeholder('zend_layout');   // or    echo $this->placeholder('zend_layout')->content; 

this can useful. mean can define places in layout.phtml display values of custom keys 'zend_layout' placeholder. instance, imagine have layout.phtml , want able modify text in footer. defining layout.phtml contain following in footer:

<div id="footer"> <?php echo $this->layout()->myfootertext; ?> </div> 

you setup default value footer in e.g. bootstrap.php. however, if wanted modify text in actions follows;

$this->view->placeholder('zend_layout')->myfootertext = 'some text action'; 

that's wanted add. off course 1 think of other scenerios, because $this->view->placeholder('zend_layout') instance of zend_view_helper_placeholder_container other things zend_layout placeholder.

edit: key 'content' default name. can change else using setcontentkey method of zend_layout, e.g.:

protected function _initsetnewlayoutcontentkey() {      $layout = $this->bootstrap('layout')->getresource('layout');      // instead of 'content' use 'viewoutput'     $layout->setcontentkey('viewoutput'); } 

with change, in layout.phtml use echo $this->layout()->viewoutput; instead of echo $this->layout()->content;.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -