cf_searchform
Simple Search Form Custom Tag:
Search Form:
page value: list.cfm
Copy and paste below into template:
<cf_searchform
cartpage="#cartpage#"
id="#variables.id#"
afid="#afid#"
text="Search"
length="12">
Copy and paste above into template.
Minimum required parameters:
id="#variables.id#" DO NOT REMOVE OR CHANGE!
afid="#afid#" DO NOT REMOVE OR CHANGE!
length="[number]" The length of the search field.
Optional parameters:
cartpage="#cartpage#" If you defined the cartpage variable in the template,
add this.
cat="#cat#" If this is included only records in the appropriate
main category will be searched.
man="#man#" If this is included only records iunder the appropriate
manufacturerwill be searched.
maxrows="[number]" Max number of records per page in search results. Defaults
to "10".
text="[text]" This will be the submit button text, or the alt text
if using an image for your button (see optional
imgsrc parameter). Defaults to "Search" if omitted.
imgsrc="[path to button]" The absolute or relative path to image submit button.
Omitting this will show a regular button for the form.
placement="[L/R/A/B]" Placement of button relative to text field.
L=Left, R=Right, A=Above or B=Below. Defaults to "B"
width="[number]" Submit Button width if using imgsrc. Must use height also
if using this.
height="[number]" Submit Button height.
inputclass="[style]" Style to use for the search text input. Add to your stylesheet.
buttonclass="[style]" Style to use for the search input button if not using
an image. Add to your stylesheet.
Special parameter:
returnhere="#cartpage#?page="
If you are using your own "cartpage" template, you may add this line, unchanged,
if you would like the cart to return to the default section of the cartpage
template you called the search from if no records are found. Otherwise, you will
be redirected to the search page in the cart. If you use this, there will be one
block of code you will need to use on the default section of the page. It will
be the text stating that no records were found. Just copy the code below the
samples and paste it at the top of the default section that you in section 2
above. You may change the text if you wish. This value may be any template, or
#cartpage# if you are calling it from cartpage and you must specify the value of
"page".
Some examples below:
returnhere="#cartpage#?page=#page#"
This example will take them back to where they searched from. One caveat. If
they are able to search from the search results page, they will be redirected to
the default section of the cartpage template so we don't get stuck in an endless
loop.
returnhere="template.cfm?page=#page#"
This one sends them to a different page from cartpage in case you have called
the search from a different page than cartpage, or if you'd just like to send
them to a different template. Again, use the dynamic page as shown, or set your
own, or use 'page=', but you must define 'page'.
returnhere="#cartpage#?page=search.cfm&adv=1"
This one is cool. It will send them to the "Advanced Search" page. Replace
cartpage with a different template if you wish.
If you are searching from a static page and returning there, put a fake
variable. Since the string returned will lead with a &, we need to start
it with a ? or the page will not be found. Example: returnhere="somepage.cfm?a="
Play around. There's probably more you can do with it.
Sample Code to place at the top of the section they will be returned to telling them...
"No Results From Search"
<CFIF records is "0" and page is not "search.cfm">
No results. Please refine your search.<p>
<CFELSEIF records GT "0" and page is not "search.cfm">
Your search returned <CFOUTPUT>#records#</CFOUTPUT> results.<br>
Please refine your search parameters.<p>
</CFIF>
By default there is a search button at the bottom of each shopping cart page
that will take the user to the search page. If you will be using this tag
throughout the site, and especially if you will be creating your own link to the
Advanced Search section with the tag below, you may hide the additional search
button (so as not to be redundant) by adding this line at the
top of the cartpage template:
<cfset hidesearch = 1>