Magento weekly admin module is empty

I am creating a custom admin module, but I canโ€™t put the contents in it, it is always empty, I try with simple code for the test, but nothing works

public function indexAction() { $this->loadLayout(); $this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHtml()); $this->renderLayout(); } 

a in .phtml

 echo 'hello world'; 

but it doesnโ€™t print anything, if you make a mistake in phtml, the system crashes, it means that it receives the file, but that I am losing please help

+6
oop php argument-passing magento
source share
1 answer

The $this->_addContent on the administrator controller expects the transfer of the block object.

 protected function _addContent(Mage_Core_Block_Abstract $block) { $this->getLayout()->getBlock('content')->append($block); return $this; } 

You go through

 $this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHtml() 

which is a string. You do it too early. If you check your logs, you will see a warning / error / that tells you that the _addContent argument is an unexpected type.

Try without calling the toHtml method

 $this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')); 
+10
source share

All Articles