Jump to content

Add Default Text in the 'Search' Bar at the top?


Recommended Posts

Hi all,

Just wondering how I can add some default text in the search bar at the top of the default PrestaShop template?

I am creating an ink site and I would like users to type in the make/model of their printer so that they can find the correct products for their printer.

Could someone please point me in the right direction? I would love to have the following text: "Enter Printer Make/Model" instead of the search bar being blank.

Thanks in advance,

JAMiE

Link to comment
Share on other sites

Change line 8 of modules/blocksearch/blocksearch-top.tpl (and blocksearch.tpl) from:

<input type="text" id="search_query" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|htmlentities:$ENT_QUOTES:'utf-8'|stripslashes}{/if}" />



to:

<input type="text" id="search_query" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|htmlentities:$ENT_QUOTES:'utf-8'|stripslashes}{else}{l s='Enter Printer Make/Model' mod='blocksearch'}{/if}" onfocus="[removed]if(this.value=='{l s='Enter Printer Make/Model' mod='blocksearch'}')this.value='';" onblur="[removed]if(this.value=='')this.value='{l s='Enter Printer Make/Model' mod='blocksearch'}';" />



Change [removed] to javascript followed by :

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

Thank you Rocky. Two more questions:

 

How to prevent user from searching the default text (Prevent from text "No results found for your search 'Enter search keywords'". It must be: "Please type a search keyword"). I have to edit search.tpl but I don't know how.

 

How do I change the text color on the onblur element? I want the Default text with a certain color and another text color (the default shop text color for forms) when the user type text.

 

Thank you.

Link to comment
Share on other sites

  • 2 months later...
  • 9 months later...

Hi, everybody.

Please, tell me what exactly should be put instead of [removed].

I cant understand where to get this JAVA script.

 

hello

 

i suggest you to create new thread with your question. Please give us also more information in your new thread what you exactly expect

 

regards

Link to comment
Share on other sites

  • 4 months later...

i realize this thread is pretty old, but if anyone stumbles upon it, the preferred solution for default text in form type inputs nowadays is the "placeholder" attribute.

So something like:

<input type="text" id="search_query" name="search_query" placeholder="Search Products ..." >

Doesn't work with old IE versions, but theres a jquery plugin to make that work if you support old IE.

  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...