Answers:
在其中创建一个.phtml
文件app/design/frontend/your_theme/default/template/catalog
,让其命名为homecategories.phtml
并将此代码粘贴到其中
<!-- Categories display start -->
<div class="home_categories">
<ul>
<?php $helper = $this->helper('catalog/category') ?>
<?php foreach ($helper->getStoreCategories() as $_category): ?>
<li>
<a href="<?php echo Mage::getModel('catalog/category')->setData($_category->getData())->getUrl(); ?>" title="<?php echo $_category->getName() ?>"><?php echo $_category->getName() ?></a>
</li>
<?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml() ?>
<!-- Categories display end -->
现在创建一个静态块,将其命名为homecategories
id,home_categories
然后将代码放入该块的内容中,以这种方式{{block type="core/template" template="catalog/homecategories.phtml"}}
调用此静态块cms.xml
<block type="cms/block" name="homecategories">
<action method="setBlockId"><block_id>home_categories</block_id></action>
</block>
从admin创建一个静态块然后
app/design/frontend/yourpackage/yourtemplate/layout
在下面的代码之下和之后创建一个local.xml文件
<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_category_layered>
<reference name="category.products">
<block type="cms/block" name="cat_static_block" >
<!--
The content of this block is taken from the database by its block_id.
You can manage it in admin CMS -> Static Blocks
-->
<action method="setBlockId"><block_id>yourblock_id</block_id></action>
</block>
</reference>
</catalog_category_layered>
<catalog_category_default>
<reference name="category.products">
<block type="cms/block" name="cat_static_block" >
<!--
The content of this block is taken from the database by its block_id.
You can manage it in admin CMS -> Static Blocks
-->
<action method="setBlockId"><block_id>yourblock_id</block_id></action>
</block>
</reference>
</catalog_category_default>
</layout>
然后转到app/design/frontend/yourpackage/yourtemplate/template/catalog/category/view.phtml
添加代码<?php echo $this->getChildHtml('cat_static_block');?>