[英]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.