Add 4 column product listing with custom layout in all categories

by Roy Andre on 10/11/2009

As you’ve might discovered there’s a bug (or an issue) in Magento when you want to define a Custom Layout Design in a category and all its child elements (sub-categories, etc).

To solve this you can change the default category layout. Please note that this will affect all categories.

  1. Open up the catalog.xml file in the layout-folder for your current Magento theme (remember to back it up before you continue)
  2. Find the element “catalog_category_default” and add the following code:

Above <reference name=”left”>, add the following code:

<reference name="root"><action method="setTemplate"><template>page/2columns-right.phtml</template></action></reference>

Next, replace the current code below the left-tag with the following code:

<reference name="content">
  <action method="unsetChild"><name>category.products</name></action>
  <action method="unsetChild"><name>product_list</name></action>
  <action method="unsetChild"><name>product_list_toolbar</name></action>
</reference>
<reference name="content">
            <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
                <block type="catalog/product_list" name="product_list" template="catalog/product/list_4col.phtml">
                    <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                    <!-- The following code shows how to set your own pager increments -->
                        <!--
                        <action method="setDefaultListPerPage"><limit>10</limit></action>
                        <action method="setDefaultGridPerPage"><limit>8</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>10</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>20</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>30</limit></action>
                        <action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>8</limit></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>16</limit></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
                        <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
                        -->
                    </block>
                    <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
                </block>
            </block>
        </reference>

Done! All your categories now use the 4column layout. Remember to include the list-4col.phtml file in the template/catalog/product-folder. If you miss this file in your Magento template let us know and we’ll send you the latest version.


Leave a Comment

Previous post: BrageTheme – New Premium Magento Templates released

Next post: Restrict access to Magento during upgrades etc