Search code examples
layoutmagentocategories

Different template for different categories in Magento


I want to display subcategories under artist category in one layout and design and other categories in another layout and design in Magento 1.4.1.1.


Solution

  • The best way to do this is to use static blocks.

    1) Create phtml file in /template/catalog/navigation

    <?php $_categories = $this->getCurrentChildCategories(); ?>
    <ul>
    <?php foreach ($_categories as $_category): ?>
    <?php if($_category->getIsActive()): ?>
    <li>
        <a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a>
    </li>
    <?php endif; ?>
    <?php endforeach; ?>
    </ul>
    

    2) Create static block "Subcategories"

    {{block type="catalog/navigation"  template="catalog/navigation/subcategory.phtml"}}
    

    3) Assign static block for needed category ("Display Settings" tab -> Display Mode = Static block only and select CMS Block "Subcategories")