Magento custom category page template

One of Magento’s weaknesses is that there often different ways to customize your installation. When several developers work on a site this often leads to inconsistencies and some ways of customizing are better than others. I was doing some research on adding a custom category template for an individual category and all solutions I found were centered around Magentos “Custom Layout Update” option which allows to overwrite the layout structure via a XML snippet in the Magento admin (Catalog > Manage Categories).

Mageno_custom_category_template

This option has several disadvantages:

  • It’s a pain to write XML in a textarea
  • There is no way of keeping track of the change in source control
  • You have to deploy this change by writing custom SQL queries or manually in your dev and staging instances

A much cleaner option is to simply do your overwrites in your themes catalog layout file catalog.xml (app/design/frontend/[package]/[theme]/layout/catalog.xml).

<!-- Category id goes here -->
<CATEGORY_[category id]>
    <reference name="root">
        <!-- Switch to 1 column layout -->
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <reference name="content">
        <!-- Overwrite the view template -->
        <block type="catalog/category_view" name="category.products" template="catalog/category/[template name].phtml" />
    </reference>
</CATEGORY_[category id]>

This approach offers the same flexibility and is much easier to deploy and maintain.

I'm available for contracting work. Check out my LinkedIn profile and my portfolio page for an overview of my skills and experience. If you are interested in working with me please use the contact form to get in touch.

Magento custom category page template

Leave a Reply

Your email address will not be published. Required fields are marked *