Main Page Flow in Zend Framework PHP

How does Zend bind $ this-> layout () -> content with /index/index.phtml scripts?

I think I don’t understand the basics of how pages should stick together. I looked at a quick start on the zend website, but it is too simplified.

+5
source share
3 answers

Since Tomas Feifar explained how it works $this->layout()->content. However, the interesting thing is that “content” is not just a variable in the layout. In fact, "content" is the key in the replacement view of the form "Zend_Layout". For this reason, the following snippets are equivalent echo $this->layout()->contentin your 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;

. , layout.phtml, Zend_Layout. , , layout.phtml . , layout.phtml, :

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

, . Bootstrap.php. , , :

$this->view->placeholder('Zend_Layout')->myFooterText = 'Some text only for this action';

, . , , $this->view->placeholder('Zend_Layout') Zend_View_Helper_Placeholder_Container, Zend_Layout placeholder.

EDIT: "" . - , setContentKey Zend_Layout, :

protected function _initSetNewLayoutContentKey() {

    $layout = $this->bootstrap('layout')->getResource('layout');

    // instead of 'content' use 'viewoutput'
    $layout->setContentKey('viewoutput');
}

layout.phtml echo $this->layout()->viewoutput; echo $this->layout()->content;.

+4

( PHTML) . ( phtml - layout.phtml). " ":) (, , ).

+1

- , , , , .

, buffer index.phtml, , .

0

All Articles