View Single Post
  #1  
Old 03-12-2011, 12:39 PM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Filter by Brand and Sort by

Hi folks,

This is my custom modification to get in products list Filter by Brand and Sort by.

skin -> customer -> search_sort_by.tpl

Code:
{* $Id: search_sort_by.tpl,v 1.2 2010/06/21 13:19:49 joy Exp $ vim: set ts=2 sw=2 sts=2 et: *} {if $sort_fields and ($url or $navigation_script)} {if $url eq '' and $navigation_script ne ''} {assign var="url" value=$navigation_script} {/if} {if $navigation_page gt 1} {assign var="url" value=$url|amp|cat:"&amp;page=`$navigation_page`"} {else} {assign var="url" value=$url|amp} {/if} <div class="search-sort-bar no-print"> <form name="filter_manufacturer" id="filter_manufacturer" style="margin: 0px; padding-right: 10px;"> <select name="filter_manufacturer_select" onchange="MM_jumpMenu('parent',this,0)" id="manspan"> <option value="">Filter by Brand</option> {section name=man loop=$found_manu} <option value="{$url}&amp;manufacturerid={$found_manu[man].manufacturerid}" {if $found_manu[man].manufacturerid eq $manufacturerid} selected="selected"{/if}>{$found_manu[man].manufacturer}</option> {/section} <option value="{$url}">All Brands</option> </select> <select name="sort_field" onchange="MM_jumpMenu('parent',this,0)"> <option value="">Sort by</option> {foreach from=$sort_fields key=name item=field} <option {if $name eq $selected and $direction eq 0}selected{/if} value="{$url}sort={$name}&sort_direction=0&amp;manufacturerid={$manufacturerid}">{$field} (Ascending)</option> <option {if $name eq $selected and $direction eq 1}selected{/if} value="{$url}sort={$name}&sort_direction=1&amp;manufacturerid={$manufacturerid}">{$field} (Descending)</option> {/foreach} </select> </form> </div> {/if}

skin -> customer -> home.tpl in <head></head>

Code:
{literal} <script> function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } </script> {/literal}


Of course the code can be improved using labels, options in Appearance.

It's working fine except 2 issues I get.

1) How can I keep always the order of brands in drop down list, no mater what option I select in Sort by list? For Default options it is working fine.

2) When no Brand, in Filter by Brand list there is an empty option at the end. How can I get rid off it?
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote