You are here:  » Hide search query


Hide search query

Submitted by guillaume on Tue, 2006-07-25 10:38 in

Hello all,

i would like to know if it's possible to hide the query in the search field when you click on a merchant name in the merchant index (merchant:MerchantName)

Thanks for your help

Submitted by support on Tue, 2006-07-25 10:59

Hi,

You have to be a bit careful about how you do this; because the value of the query ($q) is used in various places - in particular for constructing the Next and Previous links at the bottom of the search results.

The search field, as displayed by includes/searchform.php defaults to the value of $q.

Firstly, if you never wanted to display the current search you could just remove the default value; like this:

includes/searchform.php

<div class='searchform'>
  <form name='search' action='<?php print $config_baseHREF ?>search.php'>
    <input type='text' name='q' size='35' />
    <input type='submit' value='<?php print translate("Search"); ?>' />
  </form>
</div>

Now, if you only wanted to make it empty when the search was a merchant:MerchantName, you would have to do something like this:

includes/searchform.php

<?php
  if ($parts[0] == "merchant")
  {
    $searchform_default = "":
  }
  else
  {
    $searchform_default = $q;
  }
?>
<div class='searchform'>
  <form name='search' action='<?php print $config_baseHREF ?>search.php'>
    <input type='text' name='q' size='35' value='<?php print $searchform_default?>' />
    <input type='submit' value='<?php print translate("Search"); ?>' />
  </form>
</div>

Hope this helps!
Cheers,
David.

Submitted by guillaume on Tue, 2006-07-25 15:44

Yes it works like a charm :)
Thank you David for your efficient support !