magento直接在controller中创建block and setemplate

1、Loading current Layout

$this->loadLayout();

2、Create a new block  

$block = $this->getLayout->createBlock('block_template_type','test_block_name')->setTemplate(‘customer/test.phtml’);

3、Append the new block to layout

$this->getLayout->getBlock(‘content’)->append($block);//’content‘为$block的父级block的name

4、render the layout

$this->renderLayout()

 

posted @ 2016-12-02 10:49  你的左耳耳钉  阅读(180)  评论(0编辑  收藏  举报