php – Magento自定义管理模块是空白的
发布时间:2020-12-13 14:15:40 所属栏目:PHP教程 来源:网络整理
导读:我创建了一个自定义管理模块,但我不能在其中放入内容,它总是空白 我正在尝试使用简单的测试代码,但似乎没有任何工作 public function indexAction(){ $this-loadLayout(); $this-_addContent($this-getLayout()-createBlock('adminhtml/template')-setTempla
我创建了一个自定义管理模块,但我不能在其中放入内容,它总是空白
我正在尝试使用简单的测试代码,但似乎没有任何工作 public function indexAction() { $this->loadLayout(); $this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHtml()); $this->renderLayout(); } 在.phtml中 echo 'hello world'; 但是什么都不打印,如果在phtml中出错,系统崩溃,就意味着它获取文件,但是,我错过了什么
管理控制器上的$this-> _addContent方法期望传递一个块对象.
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的参数是一个意外的类型. 在没有toHtml方法调用的情况下尝试它 $this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |