PDA

View Full Version : Show text inside search box.



Petrache Nicolae
September 16, 2012, 09:43 PM
Hello. How can we have a text inside search box -like "Search the website or Search after Part Number- in multilanguage", that will go when you click and start typing? Quick search box is quite simple and that is a mean to make it easy to spot by visitors. Thanks

Vladimir
September 21, 2012, 12:15 PM
Hello,

You can try to make it the following way:



<input type="text" maxlength="255" name="f[keyword_search]" style="width: 100%;" value="{if $smarty.post.f.keyword_search}{$smarty.post.f.keyw ord_search}{else}{$lang.search_hint}{/if}" onfocus="if(this.value == '{$lang.search_hint}')this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" />

Petrache Nicolae
September 24, 2012, 08:34 AM
Hello,

You can try to make it the following way:



<input type="text" maxlength="255" name="f[keyword_search]" style="width: 100%;" value="{if $smarty.post.f.keyword_search}{$smarty.post.f.keyw ord_search}{else}{$lang.search_hint}{/if}" onfocus="if(this.value == '{$lang.search_hint}')this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" />


Hello. In keyword_search.tpl we should replace

<td><div class="keyword_search_input"><input type="text" maxlength="255" name="f[keyword_search]" style="width: 100%;" {if $smarty.post.f.keyword_search}value="{$smarty.post.f.keyword_search}"{/if}/></div></td>
with

<td><div class="keyword_search_input"><input type="text" maxlength="255" name="f[keyword_search]" style="width: 100%;" value="{if $smarty.post.f.keyword_search}{$smarty.post.f.keyw ord_search}{else}{$lang.search_hint}{/if}" onfocus="if(this.value == '{$lang.search_hint}')this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" /></div></td>?
Beside this there is something else that i should do? If the replaced code is ok, is not working. Thanks

Vladimir
September 27, 2012, 11:53 AM
Beside this there is something else that i should do? If the replaced code is ok, is not working. Thanks


Do you added the language key "search_hint" in your admin panel?

Petrache Nicolae
September 27, 2012, 12:42 PM
Do you added the language key "search_hint" in your admin panel?

nope. will try again. thanks for the tip. hope to succeed

Petrache Nicolae
September 27, 2012, 06:58 PM
Do you added the language key "search_hint" in your admin panel?

This is beyond my ability. Never done something similar so unfortunaly i do not know how to add language key "search_hint".

Steffen Buschkemper
September 27, 2012, 07:14 PM
Hi Petrache Nicolae

You have several input fields.
Therefore you have to create various language keys.
Let us make an example for your keyword search.
Just minute...

Steffen Buschkemper
September 27, 2012, 07:38 PM
Open templates/your_template/tpl/blocks/keyword_search.tpl

search this part @ line 8



<td><div class="keyword_search_input"><input type="text" maxlength="255" name="f[keyword_search]" style="width: 100%;" {if $smarty.post.f.keyword_search}value="{$smarty.post.f.keyword_search}"{/if}/></div></td>


and change with the follow code



<td><div class="keyword_search_input"><input type="text" maxlength="255" name="f[keyword_search]" style="width: 100%;" value="{if $smarty.post.f.keyword_search}{$smarty.post.f.keyw ord_search}{else}{$lang.search_hint}{/if}" onfocus="if(this.value == '{$lang.search_hint}')this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" /></div></td>



For $lang.search_hint the phrase key = search_hint

Now go in Admin Panel -> Languages and press the Button "Add a Phrase"

Key: search_hint
Value (English): Enter keyword
System module: User Interface

PS: If you have installed more languages, then you must also fill out this value for the other languages.

Press the Button "Add" and thats all.

163

Best regards
Steffen

Petrache Nicolae
September 27, 2012, 08:36 PM
Open templates/your_template/tpl/blocks/keyword_search.tpl

search this part @ line 8



<td><div class="keyword_search_input"><input type="text" maxlength="255" name="f[keyword_search]" style="width: 100%;" {if $smarty.post.f.keyword_search}value="{$smarty.post.f.keyword_search}"{/if}/></div></td>


and change with the follow code



<td><div class="keyword_search_input"><input type="text" maxlength="255" name="f[keyword_search]" style="width: 100%;" value="{if $smarty.post.f.keyword_search}{$smarty.post.f.keyw ord_search}{else}{$lang.search_hint}{/if}" onfocus="if(this.value == '{$lang.search_hint}')this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" /></div></td>



For $lang.search_hint the phrase key = search_hint

Now go in Admin Panel -> Languages and press the Button "Add a Phrase"

Key: search_hint
Value (English): Enter keyword
System module: User Interface

PS: If you have installed more languages, then you must also fill out this value for the other languages.

Press the Button "Add" and thats all.

Best regards
Steffen

nice...i didn't spot the "Add a phrase" button...I had tried to add it via phpmyadmin but too advanced for me...Thank you. Will try it now

Petrache Nicolae
September 27, 2012, 08:43 PM
Works fine in case others are interested as well. Credit goes to Vladimir for making this happen and to Steffen Buschkemper for explaing in detail what should be done. Thank you both