Jump to content

[SOLVED] search box placeholder


Recommended Posts

Change line 8 of modules/blocksearch-top.tpl (in PrestaShop v1.3.1) 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='Search' mod='blocksearch'}{/if}" onfocus="[removed]if(this.value=='{l s='Search' mod='blocksearch'}')this.value='';" onblur="[removed]if(this.value=='')this.value='{l s='Search' mod='blocksearch'}';" />



Change [removed] to javascript followed by a : and change 'Search' to the placeholder text you want.

  • Like 1
Link to comment
Share on other sites

Thank you Rocky for your reply. I implemented the code, but it doesn't work when the page is loaded. The placeholder only shows up after you've activated the search field. I tried adding the same line you used with onfocus for onload but that didnt work. Any suggestions?

Link to comment
Share on other sites

Done. I've also replaced this in the theme's global.css for styling purposes:

#header_right #search_block_top input#search_query { width: 12em }


for

#header_right #search_block_top input#search_query { width: 12em; font-style:italic; color:#999 }
#header_right #search_block_top input#search_query:focus { font-style:normal; color:#000 }

Link to comment
Share on other sites

  • 1 year later...

Hi bro´z, this dont work in PrestaShop™ 1.4.5.1

I try change to this in my blocksearch-top.tpl whith no sucess

 

<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='Search' mod='blocksearch'}{/if}" onfocus="[removed]if(this.value=='{l s='Search' mod='blocksearch'}')this.value='';" onblur="[removed]if(this.value=='')this.value='{l s='Search' mod='blocksearch'}';" />

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...