Hi there,
it seems a few people want to control the way layered navigation works, here is some code that will let you:
1. Define any attributes that you want to be displayed as a dropdown list
2. Set a threshold limit for the attributes, so that if this threshold is met, then automatically display as a dropdown list
This code needs to go into “app/design/frontend/default/[YOURTHEME]/template/catalog/layer/filter.phtml
<?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * @category design_default * @package Mage * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * */
/** * Template for filter items block * Coded by Adam Martin (www.tweakmag.com) * * * @see Mage_Catalog_Block_Layer_Filter */ ?>
<?php //control the way that the layered navigation attributes present themselves //either dropdown list or default methd (ordered list) $attributeName = $this->getName(); $itemcountthreshold = 2; // you can change this $itemcount = $this->getItemsCount(); $displayitemcount = false; //set to true/false to display item count in brackets
You will see that I have added case ‘Shoe Size’ - by doing this anytime the Shoe Size attribute is displayed it will be displayed using a dropdown. For example you could add:
@Ajazza ;
Nice work. Do you know if this will work with the final release 1.0? And can you tell me how to impliment this on the home page? We are trying to put a full category menu on the left side of all our pages? Any help would be greatly appreciated. Looks like you have this Magento under control!!!
Thanks in advance. Daniel
The code I posted works on v1.0 no problems at all. Regarding your other question about having the layered navigation on the home page - I am not 100% sure how you would go about that as the navigation is built by looking at the products / categories within the category you are viewing - homepage is not a category as such, so there is no navigation to be built. So what category would you want the layered navigation to be built from?
How would I go about hard coding the categorys? I have already set up a <div> that contains all my categories the way I want them laid out. How could I just drop that on the left column of the home page?
I know hard coding is not the way to go, but chances are my categories, once set will not change.
Thanks
Daniel
I have done the same thing on julesroc.com.au (we are currently upgrading to 1.0 at the moment). But what we did was created a new template just for the homepage that was based on the 3 columns and hardcoded the categories in. This is one approach, another is to write some xml that updates the template and inserts your phtml file that contains your customer code for linking to the categories.
I hope this helps, if you can’t follow what i said - please let me know, and I will see if I can help further tomorrow
Cheers
Adam
Thats terrific! I have not tried it out yet, but from the sounds of others, its working great. Just wanted to say mucho thanks ahead of time! Very cool.