简体   繁体   English

在magento的phtml中包括phtml文件

[英]including phtml file in phtml in magento

Hi I have added the inchoo featured products but want them to show in the header so show on everypage, i tried moving the code, i tried: 嗨,我添加了inchoo特色产品,但希望它们显示在标题中,以便在每个页面上显示,我尝试移动代码,并尝试:

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

Im kind of new to magento so i don't know 我是magento的新手,所以我不知道

thanks Graham 谢谢格雷厄姆

Create a CMS static block and give a identifier name to that, lets say "featured_product". 创建一个CMS静态块,并为其指定标识符名称,比如说“ featured_product”。 Open page.xml file from app/design/frontend/default/YOURTEMPLATE/layout/page.xml Find the section html_header, now add the following code 从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>

Next open the app/design/frontend/default/YOURTEMPLATE/template/page/html/header.phtml file. 接下来打开app / design / frontend / default / YOURTEMPLATE / template / page / html / header.phtml文件。 Find the area to design and add the following code in there : 找到要设计的区域,并在其中添加以下代码:

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

Clean cache and test your page. 清理缓存并测试您的页面。

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

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