如果不想在模板的xml中设置block或者block是动态的,那么在Magento在控制器中添加block的时候可以做下动态的调整,进而动态的修改页面。
代码如下:
$this->loadLayout(); //set view page top content $block = $this->getLayout()->createBlock( 'activitie/activitie_view', 'activitie_view', array('template' => 'hellokeykey_activitie/activitie/view.phtml') ); $this->getLayout()->getBlock('content')->insert($block); //$this->getLayout()->getBlock('content')->append($block); $this->renderLayout();
getBlock('content')是只更新content部分
append是指添加到后面,insert是添加到前面
转载表明出处:www.hellokeykey.com