Is there a way for me to display the grid view of the products in 1 category page only and the rest are in list view?
2 Answers
You can achieve this by layout update. This will be the best way to do this.
For this I assume, the category that you need to show in list has an id 11. In that case create local.xml
file like this.
File: app/design/frontend/<your_package>/<your_theme>/layout/local.xml
<layout>
<CATEGORY_11>
<reference name="product_list_toolbar">
<action method="setData"><data>_current_grid_mode</data><mode>grid</mode></action>
</reference>
</CATEGORY_11>
<catalog_category_default>
<reference name="product_list_toolbar">
<action method="setData"><data>_current_grid_mode</data><mode>list</mode></action>
</reference>
</catalog_category_default>
<catalog_category_layered>
<reference name="product_list_toolbar">
<action method="setData"><data>_current_grid_mode</data><mode>list</mode></action>
</reference>
</catalog_category_layered>
</layout>
This will make category with id 11 in grid view and rest of categories in grid view.
What you need to do here is, just replace 11
with your category id. You can get id of a category from admin side. Go to Catalog > Manage Categories
. Select category that you need to show in grid. You can see its id in top section.
Hope that helps
-
hey that works! but when I try to have other page layout (eg: with left sidebar), it doesn't have a sidebar Commented Sep 3, 2014 at 4:09
-
-
If this answer helped you to resolve the problem in question, feel free to accept this as answer. If you have further doubts, ask it as another question Commented Sep 3, 2014 at 4:12
-
I try to change the layout of the category into 2 columns which I have main content and left or right sidebar. but sidebar doesn't appear Commented Sep 3, 2014 at 4:17
-
you need to set page layout for that category. Use this for that
<reference name="root"> <action method="setTemplate"><template>page/2columns-left.phtml</template></action></reference>
Commented Sep 3, 2014 at 4:40
yes sure,you can do this...
rewrite the block Mage_Catalog_Block_Product_List_Toolbar
protected function _construct()
{
parent::_construct();
if (Mage::registry('current_category')->getId()==yourmatchcatid && Mage::registry('current_category') ) {
$this->_availableMode = array('grid' => $this->__('Gird')); available modes to grid only.
}
}
Or
copy
app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php to
app\code\local\Mage\Catalog\Block\Product\List\Toolbar.php add this code to
if (Mage::registry('current_category')->getId()==youmatchmatcCatId && Mage::registry('current_category') ) {
$this->_availableMode = array('grid' => $this->__('Grid'));
}
Just before $this->setTemplate('catalog/product/list/toolbar.phtml');
at _construct
function
Note:This code is remove list of view option from that particular category category...