I want to create a static block which displays all of my categories and displays them in a list. I don't need an image and I don't need the sub categories.
Then I want to add this block to my home page.
Create one .phtml
file inside app/design/frontend/your_theme/default/template/catalog
lets name it as homecategories.phtml
and paste this code into it
<!-- 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 -->
now create a static block lets name it as homecategories
id as home_categories
and now place this code into content of that block {{block type="core/template" template="catalog/homecategories.phtml"}}
now call this static block in your cms.xml
in this way
<block type="cms/block" name="homecategories">
<action method="setBlockId"><block_id>home_categories</block_id></action>
</block>
Create a static block from admin Then
create a local.xml file under app/design/frontend/yourpackage/yourtemplate/layout
and past the below code
<?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>
and goto app/design/frontend/yourpackage/yourtemplate/template/catalog/category/view.phtml
add code <?php echo $this->getChildHtml('cat_static_block');?>