2016-02-27 160 views
0

我收到错误,如下面显示在Magento管理面板

Recoverable Error: Argument 1 passed to Mage_Adminhtml_Controller_Action::_addContent() must be an instance of Mage_Core_Block_Abstract, boolean given, 

我的indexAction的代码是像下面

public function indexAction() 
    { 
     // instantiate the grid container 
     $brandBlock = $this->getLayout() 
      ->createBlock('digitech_brandlogo_adminhtml/brandlogo'); 

     // Add the grid container as the only item on this page 
     $this->loadLayout() 
      ->_addContent($brandBlock) 
      ->renderLayout(); 
    } 

在这种情况下,我的问题是,这是什么意思“

$brandBlock = $this->getLayout() 
       ->createBlock('digitech_brandlogo_adminhtml/brandlogo'); 

“?? ??

我想知道有关块和布局结构/安排。

回答

0

对不起,迟到的回答可能是这样一个帮助别人 您可以使用此代码,请与您的块名称和模板路径

public function indexAction() 
{ 
//Get current layout state 
$this->loadLayout(); 

$block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template', 
'my_block_name_here', 
array('template' => 'activecodeline/developer.phtml') 
); 

$this->getLayout()->getBlock('content')->append($block); 

$this->renderLayout(); 
} 
替换“my_block_name_here”和“activecodeline/developer.phtml”