建立了static block后,如何在前端界面显示呢?
本实例基于magento 1.5,这里我举例创建一个banner在header.phtml部分,因为每一个页面都要调用到。
第一步、找到模板文件下的header.phtml,在你需要的位置添加:
|
<div class="ad"> <?php echo $this->getChildHtml('cms_ad') ?> <?php echo $this->getChildHtml('ad') ?> </div> |
第二步、在layout文件中寻找cms.xml设置静态块:
|
<default> <referencename="header"> <blocktype="cms/block"name="cms_ad"before="ad"> <!-- The content of this block is taken from the database by its block_id. You can manage it in admin CMS -> Static Blocks --><actionmethod="setBlockId"><block_id>ad</block_id></action> </block> </reference> </default> |