Magento Category Pages: Change layout of specific categories from grid mode to list mode

I want some category pages to be in the list mode and to start with 30 items displayed but I want another category page to be in grid mode and with fewer items displayed.

I understand that I can do this by updating the custom layout xml through the admin panel, but I'm not sure what the exact XML would be.


My solution was to create a module that overrides the Toolbar class which is what controls the grid/list view of the catalog and the number of items to display.

The specific class to override is called Mage_Catalog_Block_Product_List_Toolbar. Clone the file and add the following method to it:

 * Sets the current View mode (grid, list, etc.)
 * @param string $mode
public function setCurrentMode($mode)
    $this->setData('_current_grid_mode', $mode);

You also need to create a config.xml file for it.

<!-- app/code/local/Example/Catalog/etc/config.xml -->
<?xml version="1.0"?>

Now, in the admin panel, to change the layout of a category, go to Catalog > Manage Categories and select the category that you wish to change. Go to the Custom Design tab and in the field labelled Custom Layout Update, enter the following XML code:

<reference name="product_list_toolbar">
  <action method="setCurrentMode">

Of course, remember to flush the layout caches of Magento or your change won't appear.

Need Your Help

How does str(list) work?

python string list eval python-internals

Why does str(list) returns how we see list on the console? How does str(list) work? (any reference to the CPython code for str(list))?