X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Search box with dropdown (https://forum.x-cart.com/showthread.php?t=58450)

vitalaccessories 03-13-2011 11:55 PM

Search box with dropdown
 
Hi there,

I am looking to see whether I can put in a dropdown box from the default search box containing pre-selected searches on the homepage? Basically customers can then either enter free text for a search or choose from a specific search which I have chosen via the dropdown...

Any help would be appreciated, thanks.

vasilis 03-14-2011 03:07 AM

Re: Search box with dropdown
 
The template file responsible for the search box is customer/search.tpl template file:

Code:

<div class="search">
  <div class="valign-middle">
    <form method="post" action="search.php" name="productsearchform">

      <input type="hidden" name="simple_search" value="Y" />
      <input type="hidden" name="mode" value="search" />
      <input type="hidden" name="posted_data[by_title]" value="Y" />
      <input type="hidden" name="posted_data[by_descr]" value="Y" />
      <input type="hidden" name="posted_data[by_sku]" value="Y" />
      <input type="hidden" name="posted_data[search_in_subcategories]" value="Y" />
      <input type="hidden" name="posted_data[including]" value="all" />

      {strip}

        <input type="text" name="posted_data[substring]" class="text{if not $search_prefilled.substring} default-value{/if}" value="{$search_prefilled.substring|default:$lng.lbl_search|escape}" />
        {include file="customer/buttons/button.tpl" type="input" style="image"}
        <a href="search.php" class="search">{$lng.lbl_advanced_search}</a>
      {/strip}

    </form>

  </div>
</div>


In red color is the code for the display of the input text control. I guess you could replace the text type input with a select input (or add beside it so you could have both a text input and a drop-down input), something like:

Code:

<select name="posted_data[substring]" class="text{if not $search_prefilled.substring} default-value{/if}" value="{$search_prefilled.substring|default:$lng.lbl_search|escape}" />
          <option>option 1</option>
          <option>option 2</option>
          <option>option 3</option>
          ..................................
          ..................................
 </select>


I hope, it works out for you...

vitalaccessories 03-14-2011 11:51 AM

Re: Search box with dropdown
 
Hi,

Thanks a lot for the reply. That looks like just the ticket. I will be implementing this soon.:D

Regards.


All times are GMT -8. The time now is 08:52 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.