`
hudeyong926
  • 浏览: 2016364 次
  • 来自: 武汉
社区版块
存档分类
最新评论

Magento 返回不带Layout的页面输出

 
阅读更多

2. 在controller的代码方式创建并输出block内容

$this->loadLayout();
$this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/catalog_product_grid')->toHtml()
); 

3一旦使用PHTML模板文件,有如下两种方法完成同样效果
1).使用core/text_list的Block命名为root

<your_frontname_controller_action>
	<block type="core/text_list" name="root">
		<block type="block1" name="block1" template="block1.phtml"/>
		<block type="block2" name="block2" template="block2.phtml"/>
	</block>
</your_frontname_controller_action>

 2). 建立空的layout文件,如
a). page/empty.phtml内容如下:

<?php echo $this->getChildHtml('content') ?>

 b). layout的文件声明可能如下

<your_frontname_controller_action translate="label">
  <reference name="root">
    <action method="setTemplate"><template>page/empty.phtml</template />
  </reference>
  <reference name="content">
    <block type="{your_block} name="{blockname}" template="{your_template_file.phtml}" />
  </reference>
</your_frontname_controller_action>

 第2种方法使用是最频繁的

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics