Cas*_*Roy 6 php oop magento argument-passing
我已经创建了一个自定义管理模块,但我不能在其中放入内容,它总是空白我正在尝试使用简单的测试代码,但似乎没有任何工作
public function indexAction()
{
$this->loadLayout();
$this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHtml());
$this->renderLayout();
}
Run Code Online (Sandbox Code Playgroud)
在.phtml中
echo 'hello world';
Run Code Online (Sandbox Code Playgroud)
但是什么都不打印,如果在phtml中出错,系统崩溃,就意味着它得到了文件,但是,我想要的是什么,请帮助
Ala*_*orm 10
的$this->_addContent一个管理器上的方法期望被传递一个块对象.
protected function _addContent(Mage_Core_Block_Abstract $block)
{
$this->getLayout()->getBlock('content')->append($block);
return $this;
}
Run Code Online (Sandbox Code Playgroud)
你在路过
$this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHtml()
Run Code Online (Sandbox Code Playgroud)
这是一个字符串.你现在渲染太快了.如果你检查你的日志,你会看到一个警告/错误/告诉你参数_addContent是一个意外的类型.
在没有toHtml方法调用的情况下尝试它
$this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml'));
Run Code Online (Sandbox Code Playgroud)