
如果我们看看继承的_addContent
方法,我们可以看到它是如何工作的。
/**
* @return Mage_Adminhtml_Controller_Action
*/
protected function _addContent(Mage_Core_Block_Abstract $block)
{
$this->getLayout()->getBlock('content')->append($block);
return $this;
}
首先,Magento获取对当前布局的内容块的引用。这就是为什么我们的块添加代码必须在我们调用该loadLayout
方法之后。接下来,最后,Magento将传入的块附加到上述内容块。