-
-
Save jagmitg/2286032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
if($itemcount > $itemcountthreshold){ | |
$attributeName = "Overthreshold"; | |
} | |
if(!function_exists("_displayOrderedlist")){ | |
function _displayOrderedlist($atts,$displayitemcount){ | |
echo '<ol>'; | |
foreach($atts->getItems() as $_item){ | |
echo '<li><a href="'.$_item->getUrl().'">'.$_item->getLabel().'</a>'; | |
if($displayitemcount){ | |
echo ' ('.$_item->getCount().')'; | |
} | |
echo '</li>'; | |
} | |
echo '</ol>'; | |
} | |
} | |
if(!function_exists("_displayDropdown")){ | |
function _displayDropdown($atts,$displayitemcount){ | |
echo '<select id="layered-select" class="select" name="layered-select" onchange="if (this.selectedIndex > 0) location.href=this[this.selectedIndex].value;">'; | |
echo '<option selected="selected">Please select</option>'; | |
foreach ($atts->getItems() as $_item){ | |
echo '<option value="'.$_item->getUrl().'">'; | |
echo $_item->getLabel(); | |
if($displayitemcount){ | |
echo ' ('.$_item->getCount().')'; | |
} | |
echo '</option>'; | |
} | |
echo '</select>'; | |
} | |
} | |
switch ($attributeName) { | |
case 'Shoe Size': | |
case 'Overthreshold': | |
_displayDropdown($this,$displayitemcount); | |
break; | |
default: | |
_displayOrderedlist($this,$displayitemcount); | |
break; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment