Magento 将块附加到另一个块
我从这里开始学习官方教程 当我尝试将一个块附加到另一个块时,我遇到了一个问题。我使用下面的代码(与教程-2中使用的代码非常类似),但它不起作用。Magento 将块附加到另一个块,magento,Magento,我从这里开始学习官方教程 当我尝试将一个块附加到另一个块时,我遇到了一个问题。我使用下面的代码(与教程-2中使用的代码非常类似),但它不起作用。$block->toHtml()返回空字符串,但$block包含一个大数组 class Custom_HelloWorld_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->l
$block->toHtml()
返回空字符串,但$block
包含一个大数组
class Custom_HelloWorld_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction() {
$this->loadLayout();
$block = $this->getLayout()->createBlock('newsletter/subscribe');
$this->getLayout()->getBlock('content')->append($block);
$this->renderLayout();
}
}
如果我使用XML文件来做同样的事情,一切都会顺利。新闻稿/订阅块扩展了Mage_Core_block_模板,但没有在其构造函数中设置默认的*.phtml文件。看 因此,您需要执行类似于
$block->setTemplate(“newsletter/subscribe.phtml”)渲染布局之前,请执行“代码>”