Advertisement
Guest User

my code

a guest
Feb 12th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.63 KB | None | 0 0
  1. <?php
  2.     /**
  3.      * Magento
  4.      *
  5.      * NOTICE OF LICENSE
  6.      *
  7.      * This source file is subject to the Open Software License (OSL 3.0)
  8.      * that is bundled with this package in the file LICENSE.txt.
  9.      * It is also available through the world-wide-web at this URL:
  10.      * http://opensource.org/licenses/osl-3.0.php
  11.      * If you did not receive a copy of the license and are unable to
  12.      * obtain it through the world-wide-web, please send an email
  13.      * to license@magentocommerce.com so we can send you a copy immediately.
  14.      *
  15.      * @category   design_default
  16.      * @package    Mage
  17.      * @copyright  Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
  18.      * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  19.      *
  20.      */
  21.    
  22.     /**
  23.      * Template for filter items block
  24.      * Coded by Adam Martin (www.tweakmag.com)
  25.      *
  26.      *
  27.      * @see Mage_Catalog_Block_Layer_Filter
  28.      */
  29.     ?>
  30.  
  31.  
  32. <?php
  33.     //control the way that the layered navigation attributes present themselves
  34.     //either dropdown list or default methd (ordered list)
  35.     $attributeName = $this->getName();
  36.     $itemcountthreshold = 0; // you can change this
  37.     $itemcount = $this->getItemsCount();
  38.     $displayitemcount = false; //set to true/false to display item count in brackets
  39.    
  40.    
  41.     /*if($itemcount > $itemcountthreshold){
  42.         $attributeName = "Overthreshold";
  43.     }*/
  44.    
  45.     if($itemcount > $itemcountthreshold && !($attributeName == 'Category')){
  46.         $attributeName = 'Overthreshold';
  47.     }
  48.    
  49.    
  50.    
  51.     if(!function_exists("_displayOrderedlist")){
  52.         function _displayOrderedlist($atts,$displayitemcount){
  53.             echo '<ol>';
  54.             foreach($atts->getItems() as $_item){
  55.                 //echo '<li><a href="'.$_item->getUrl().'">'.$_item->getLabel().'</a>';
  56.                 echo '<li class="filter-category-list"><a href="'.$_item->getUrl().'">'.$_item->getLabel().'</a>';
  57.  
  58.                 if($displayitemcount){
  59.                     echo ' ('.$_item->getCount().')';
  60.                 }
  61.                 echo '</li>';
  62.             }                
  63.             echo '</ol>';
  64.         }
  65.     }
  66.     if(!function_exists("_displayDropdown")){
  67.         function _displayDropdown($atts,$displayitemcount){
  68.             echo '<select id="layered-select" class="select" name="layered-select" onchange="if (this.selectedIndex > 0) location.href=this[this.selectedIndex].value;">';
  69.             //echo '<option selected="selected">Select</option>';
  70.            
  71.             /* Home page filters */
  72.             /* If current url == Home page, redirect active filters to the all-products page with current filters still active */
  73.             if ($_SERVER['REQUEST_URI'] == '/') {
  74.                 echo '<option selected="selected">By ' .Mage::helper('catalog')->__($atts->getName()). '</option>'; // Print attribute name instead of "select"
  75.                 echo '<option value=""> ---------- </option>'; // Adding separator
  76.             foreach ($atts->getItems() as $_item) { ?>
  77.                 <option value="/all-products.html?
  78.                     <?php
  79.                         echo $_item->getFilter()->getAttributeModel()->getAttributeCode(); // Getting attribute code (name identifier)
  80.                         echo '=';
  81.                         echo $_item->getValueString(); // Getting attribute value number
  82.                     ?>
  83.                 ">
  84.                 <?php
  85.                 echo $_item->getLabel();
  86.                 if($displayitemcount){
  87.                         echo ' ('.$_item->getCount().')';
  88.                 }
  89.                 echo '</option>';
  90.             }
  91.  
  92.             } else {
  93.                 /* End home page filters */
  94.                
  95.                 /* Filters on category pages */
  96.                 echo '<option selected="selected">By ' .Mage::helper('catalog')->__($atts->getName()). '</option>'; // Print attribute name instead of static "select"
  97.                 echo '<option value=""> ---------- </option>'; // Adding separator
  98.    
  99.                 foreach ($atts->getItems() as $_item){
  100.                     echo '<option value="'.$_item->getUrl().'">';
  101.                     echo $_item->getLabel();
  102.                     if($displayitemcount){
  103.                         echo ' ('.$_item->getCount().')';
  104.                     }
  105.                     echo '</option>';
  106.                 }
  107.                 /* End category page filters */
  108.             }
  109.             echo '</select>';
  110.         }
  111.     }
  112.    
  113.     switch ($attributeName) {
  114.         case 'Shoe Size':
  115.         case 'Overthreshold':
  116.             _displayDropdown($this,$displayitemcount);
  117.             break;
  118.            
  119.         default:
  120.             _displayOrderedlist($this,$displayitemcount);
  121.             break;
  122.     }    
  123.  
  124.    
  125.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement