Created
September 6, 2011 20:08
-
-
Save joeyblake/1198806 to your computer and use it in GitHub Desktop.
product search filter
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
<cffunction name="productSearchBar" displayname="Product Search Bar" access="public" output="true"> | |
<cfargument name="formid" hook="formid" displayname="Form Name" required="yes" type="numeric"> | |
<cf_ccms_getdata_ptsi formid="#formid#" thisthing=true> | |
<cfparam name="url.brand" default=""> | |
<cfparam name="url.category" default=""> | |
<cfparam name="url.subcategory" default=""> | |
<cfif url.brand neq "" AND url.category neq ""> | |
<cfset bd = lcase(ListFirst(url.brand,"'"))> | |
<cfset whereclse = ""> | |
<cfif url.brand NEQ '0'> | |
<cfset whereclse &= "WHERE LOWER(Brand) like '%#bd#%'"> | |
</cfif> | |
<cfif url.category NEQ '0'> | |
<cfif whereclse NEQ ""> | |
<cfset whereclse &= " AND"> | |
<cfelse> | |
<cfset whereclse &= "WHERE"> | |
</cfif> | |
<cfset whereclse &= " LOWER(Categories) like '%#lcase(url.category)#%'"> | |
</cfif> | |
<cfquery dbtype="query" name="trimSubcats"> | |
SELECt * FROM qry #PreserveSingleQuotes(whereclse)# | |
</cfquery> | |
</cfif> | |
<cfset brand = ListSort(List_Dedupe(ValueList(qry.Brand)),"textnocase","asc")> | |
<cfset category = ListSort(List_Dedupe(ValueList(qry.Categories)),"textnocase","asc")> | |
<cfif isDefined('trimSubcats')> | |
<cfset subcategory = ListSort(List_Dedupe(ValueList(trimSubcats.SubCategory)),"textnocase","asc")> | |
<cfelse> | |
<cfset subcategory = ListSort(List_Dedupe(ValueList(qry.SubCategory)),"textnocase","asc")> | |
</cfif> | |
<form class="product_select" action="/results.cfm" method="get" style="width:185px; float:right; display:block; margin:0px; padding:0px;"> | |
<select class="selectbox" name="brand" onchange="rxsubmit(this.form)"> | |
<option value="any">Brand</option> | |
<cfloop list="#brand#" index=i> | |
<option value="#URLencodedFormat(i)#" <cfif url.brand EQ #i#>selected</cfif> >#i#</option> | |
</cfloop> | |
</select> | |
<select class="selectbox" name="category" onchange="rxsubmit(this.form)"> | |
<option value="any">Category</option> | |
<cfloop list="#category#" index=i> | |
<option value="#i#" <cfif url.category EQ #i#>selected</cfif> >#i#</option> | |
</cfloop> | |
</select> | |
<select class="selectbox" name="subcategory" onchange="rxsubmit(this.form)"> | |
<option value="any">Sub Category</option> | |
<cfloop list="#subcategory#" index=i> | |
<option value="#i#" <cfif url.subcategory EQ #i#>selected</cfif> >#i#</option> | |
</cfloop> | |
</select> | |
<input type="image" style="vertical-align:bottom; float:right; margin-top:3px; margin-right:2px; display:inline;" src="/images/search_btn.jpg" /> | |
</form> | |
Search | |
<form class="product_select" action="/results.cfm" method="get" style="width:232px; float:right; display:block; margin:0px; margin-top:6px; padding:0px;"> | |
Search <input type="text" name="keyword" style="width:151px; margin-left:5px;" /><input type="image" style="vertical-align:bottom;float:right;margin-top:3px; margin-right:2px;" src="/images/search_btn.jpg" /> | |
</form> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment