If you decide to use the method described by @ rengaw83, you will no longer be able to switch between modes in this category. For example, if you click "Grid", the mode will not be changed to grid mode.
To be able to switch modes and simply set the default view mode in a category using a custom layout, you need to override the main block of the toolbar and add the following method to it:
public function setCurrentModes($modes) { $this->_availableMode = $modes; $modes = array_keys($this->_availableMode); $defaultMode = current($modes); $mode = $this->getRequest()->getParam($this->getModeVarName()); if ($mode) { if ($mode == $defaultMode) { Mage::getSingleton('catalog/session')->unsDisplayMode(); } } else { $mode = Mage::getSingleton('catalog/session')->getDisplayMode(); } if (!$mode || !isset($this->_availableMode[$mode])) { $mode = $defaultMode; } $this->setData('_current_grid_mode', $mode); }
Then you can configure the modes in the custom layout tab as follows:
<reference name="product_list_toolbar"> <action method="setCurrentModes"> <modes> <list>List</list> <grid>Grid</grid> </modes> </action> </reference>
for default list mode or
<reference name="product_list_toolbar"> <action method="setCurrentModes"> <modes> <grid>Grid</grid> <list>List</list> </modes> </action> </reference>
for the default grid mode. Or you can even pass only one mode to set only the grid or list mode.
source share