2016-02-27 201 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」