2012-05-01 190 views
0

我当前正在尝试将块添加到自定义Adminhtml模块。我能够显示块的内容,但是它以灰色背景在页面的顶部呈现,然后是设计和菜单直接在底下呈现的标准magento布局。将块添加到magento adminhtml模块

即时尝试以正确的方式做事情,以了解最佳做法,并遵循书籍和教程以及magento核心,但迄今为止一直无法正确添加内容。

到目前为止,我有:

public function indexAction() 
{ 
    $this->loadLayout(); 
    $this->_setTitle(); 
    $main_block = new Invent_General_Block_Info(); 
    echo $main_block->toHtml(); 
    //$this->_addContent($main_block); 
    $this->renderLayout(); 

我能看到的一般方式在法师核心这样做会是这样的

/** 
    * Append customers block to content 
    */ 
    $this->_addContent(
     $this->getLayout()->createBlock('adminhtml/customer', 'customer') 
    ); 

,因为我已经创建了块$ main_block它对我来说没有意义 - > createBlock,所以我不知道该从这里做什么。

像往常一样赞赏任何帮助。谢谢!

回答

5

创建我发现,解决了这个问题的答案。

当然它会来自艾伦风暴。谢谢艾伦。线程被发现here

所以要解决这个问题,我所做的就是:

创建应用程序/设计文件夹/ adminhtml/mythemename/info.phtml

,然后在我的控制器动作我根本:

$this->loadLayout(); 
    $this->_setTitle(); 
$this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('shipment/info.phtml')); 
    $this->renderLayout(); 

它工作的很棒。

0

使用此如果静态块您通过CMS

/** 
    * Append customers block to content 
    */ 

$this->_addContent(
    $this->getLayout() 
    ->createBlock('cms/block') 
    ->setBlockId('{block_name}') 
    ->toHtml() 
); 
+0

嗨感谢您的建议,但这并没有奏效,因为我没有通过CMS创建块,但已经这样编程。 – activeDev