답변:
.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>
관리자로부터 정적 블록 만들기
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');?>