Magento 以编程方式创建block

如果我们看看继承的_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将传入的块附加到上述内容块。

本文参考:
https://alanstorm.com/magento_admin_controllers/

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用 * 标注