简体   繁体   中英

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:

 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

thanks Graham

Create a CMS static block and give a identifier name to that, lets say "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

<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. Find the area to design and add the following code in there :

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

Clean cache and test your page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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