Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

set minimum number of characters in search string. HOW PLS?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-28-2006, 10:32 AM
 
donavichi donavichi is offline
 

X-Adept
  
Join Date: Apr 2004
Location: United Kingdom
Posts: 697
 

Default set minimum number of characters in search string. HOW PLS?

By default, in x-cart if you hit 'Submit' in the search field with no search query in the search field, x-cart returns all products listed in the database.

This is not desirable for a number of reasons and I was wondering if you could help me change this to actually set a minimum number of characters required before a search result is returned to the user, thus reducing the number of items displayed.

Or if there is a better solution which is implementable could you suggest what one might do to avoid the aforementioned scenario?

Thanks a heap
__________________
Best regards,

Donavichi.
- - -

Website Copywriting || Web Design || FAQs || Home & Garden Blog
Reply With Quote
  #2  
Old 03-28-2006, 10:34 AM
 
Lionel Lionel is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 199
 

Default

I am also anxious for a solution. The closest I found so far involves adding a validator plugin into smarty.
__________________
X-Cart Gold 4.0.17 [unix]
X-Cart Gold 4.0.18 [unix]
Reply With Quote
  #3  
Old 04-03-2006, 06:56 AM
 
Lionel Lionel is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 199
 

Default

I was able to find something to prevent the blank searches and minimum characters. Set the var minLength to desired character length.

here is the capture section in search.tpl

Code:
{capture name=search} <TABLE border="0" cellpadding="0" cellspacing="0"> <FORM method="POST" action="search.php" name="productsearchform" OnSubmit="return submitSearchFrm();"> <INPUT type="hidden" name="simple_search" value="Y"> <INPUT type="hidden" name="mode" value="search"> <INPUT type="hidden" name="posted_data[substring]" value="" id="search_substring"> <INPUT type="hidden" name="posted_data[by_title]" value="Y"> <INPUT type="hidden" name="posted_data[by_shortdescr]" value="Y"> <INPUT type="hidden" name="posted_data[by_fulldescr]" value="Y"> <TR> <TD align="right" valign="middle"> {literal} <SCRIPT language="JavaScript"> function submitSearchFrm() { var minLength = 3; var frm = document.productsearchform; if (frm.search_for.value == "" || frm.search_for.value.length < minLength) { alert ("Please enter a minimum of 3 characters"); return false; } var search_substring = document.getElementById("search_substring"); search_substring.value = frm.search_for.value; return true; } </SCRIPT> {/literal} <INPUT style="border:1px inset #C0C0C0; color:#000000; background:#F4F4F4; height:17px; width:110px;" type="text" name="search_for" size="20" value="{$search_prefilled.substring|escape}"> </TD> <TD align="left" valign="middle"> <A href="javascript: if (submitSearchFrm()) document.productsearchform.submit();void(0);">{include file="buttons/search_head.tpl"}</A></TD></TR><TR> <TD align="center" colspan="2"> {$lng.lbl_advanced_search}</TD> </TR> </FORM> </TABLE> {/capture}
__________________
X-Cart Gold 4.0.17 [unix]
X-Cart Gold 4.0.18 [unix]
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:35 PM.

   

 
X-Cart forums © 2001-2020