【发布时间】:2023-03-22 13:46:01
【问题描述】:
我目前正在开发一个 Magento 扩展,并且我已经覆盖了一个核心控制器,它工作正常。
我现在已经向我的控制器添加了一个新动作。问题是,每当我调用该操作时,都会生成一个空白页。如果我回显某些内容,它会正确显示。
因此,我深入研究了客户模块和控制器的核心。我在那里看到像indexAction() 这样的方法以这种方式实现布局:
<?php
public function indexAction()
{
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('catalog/session');
$this->getLayout()->getBlock('content')->append(
$this->getLayout()->createBlock('customer/account_dashboard')
);
$this->getLayout()->getBlock('head')->setTitle($this->__('My Account'));
$this->renderLayout();
}
我将其转移到我自己的操作中,现在布局已正确呈现。现在回答问题:
无论我在->createBlock('...') 调用中输入什么内容,都不会在内容区域中呈现任何内容。
如何指定我自己的块的位置以呈现为页面的内容,同时仍然用布局装饰它?
我尝试摆弄 /design/frontend/base/default/layout/myaddon.xml 中的 xml 文件,但无法真正发挥作用。
【问题讨论】:
标签: php magento e-commerce