Je veux créer un bloc statique qui affiche toutes mes catégories et les affiche dans une liste. Je n'ai pas besoin d'une image et je n'ai pas besoin des sous-catégories.
Ensuite, je veux ajouter ce bloc à ma page d'accueil.
Je veux créer un bloc statique qui affiche toutes mes catégories et les affiche dans une liste. Je n'ai pas besoin d'une image et je n'ai pas besoin des sous-catégories.
Ensuite, je veux ajouter ce bloc à ma page d'accueil.
Réponses:
Créer un .phtmlfichier à l'intérieur app/design/frontend/your_theme/default/template/catalogpermet de le nommer homecategories.phtmlet d'y coller ce code
<!-- 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 -->
maintenant créer un bloc statique permet de le nommer comme homecategoriesid home_categorieset maintenant de placer ce code dans le contenu de ce bloc {{block type="core/template" template="catalog/homecategories.phtml"}}maintenant appeler ce bloc statique de votre cms.xmlfaçon
<block type="cms/block" name="homecategories">
<action method="setBlockId"><block_id>home_categories</block_id></action>
</block>
Créer un bloc statique à partir d'admin Puis
créer un fichier local.xml sous app/design/frontend/yourpackage/yourtemplate/layoutet après le code ci-dessous
<?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>
et allez app/design/frontend/yourpackage/yourtemplate/template/catalog/category/view.phtml
ajouter du code<?php echo $this->getChildHtml('cat_static_block');?>