Magento自定义管理模块为空 [英] Magento custom admin module is blank
问题描述
我已经创建了一个自定义管理模块,但是我无法在其中添加内容,它始终为空白 我正在尝试使用简单的代码进行测试,但似乎无济于事
I've create a custom admin module but i can't put a content in it, it always is blank i'm trying with a simple code for test, but nothing seem to work
public function indexAction()
{
$this->loadLayout();
$this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHtml());
$this->renderLayout();
}
.phtml中的
an in the .phtml
echo 'hello world';
但不输出任何内容,如果phtml中出现错误,系统崩溃,则意味着它正在获取文件,但是,我想念的是 请帮助
but doesn't print nothing, if a make an error in the phtml, the system crash, it means that its getting the file, but, what i'm i missing please, help
推荐答案
管理控制器上的$this->_addContent
方法希望传递给块对象.
The $this->_addContent
method on an admin controller expects to be passed a block object.
protected function _addContent(Mage_Core_Block_Abstract $block)
{
$this->getLayout()->getBlock('content')->append($block);
return $this;
}
您正在传递
$this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHtml()
这是一个字符串.您渲染得太早了.如果检查日志,应该会看到警告/错误/提示,表明_addContent
的参数是意外类型.
which is a string. You're rendering it too soon. If you check your logs you should see a warning/error/something telling you that the argument to _addContent
is an unexpected type.
尝试不使用toHtml方法调用
Try it without the toHtml method call
$this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml'));
这篇关于Magento自定义管理模块为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!