繁体   English   中英

在magento的phtml中包括phtml文件

[英]including phtml file in phtml in magento

嗨,我添加了inchoo特色产品,但希望它们显示在标题中,以便在每个页面上显示,我尝试移动代码,并尝试:

 echo $this->getLayout()->createBlock('Mage_Adminhtml_Block_Template', 'block-name')->setData('template', 'inchoo/block_featured_products.phtml')->toHtml()

我是magento的新手,所以我不知道

谢谢格雷厄姆

创建一个CMS静态块,并为其指定标识符名称,比如说“ featured_product”。 从app / design / frontend / default / YOURTEMPLATE / layout / page.xml打开page.xml文件,找到html_header部分,现在添加以下代码

<block type="cms/block" name="header_block"><action method="setBlockId"><block_id>featured_product</block_id></action></block>

接下来打开app / design / frontend / default / YOURTEMPLATE / template / page / html / header.phtml文件。 找到要设计的区域,并在其中添加以下代码:

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

清理缓存并测试您的页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM