Junaid Khawaja Posted May 4, 2014 Share Posted May 4, 2014 (edited) I am customizing a theme so I want to add small magnifier icon in searchbar appeared in top menu. Moreover, I want to add a default value in that searchbox that will be hide when user click on the searchbox. I edited the template block search files under themes folder but no help. Is there any other way to do this? P.S. I am using the Prestashop 1.6 with default bootstrap theme. My website is play.game5ive.com Edited May 4, 2014 by Junaid Khawaja (see edit history) Link to comment Share on other sites More sharing options...
dioniz Posted May 4, 2014 Share Posted May 4, 2014 That search bar is located in topmenu. You can add search icon in css. For text in search box open yourtheme/modules/blocktopmenu/blocktopmenu.tpl and change this code <input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> to this <input type="text" placeholder="Yourtext" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> 1 Link to comment Share on other sites More sharing options...
Junaid Khawaja Posted May 4, 2014 Author Share Posted May 4, 2014 That search bar is located in topmenu. You can add search icon in css. For text in search box open yourtheme/modules/blocktopmenu/blocktopmenu.tpl and change this code <input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> to this <input type="text" placeholder="Yourtext" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> That search bar is located in topmenu. You can add search icon in css. For text in search box open yourtheme/modules/blocktopmenu/blocktopmenu.tpl and change this code <input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> to this <input type="text" placeholder="Yourtext" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> I was making all those changes to blocksearch.tpl and blocksearchtop.tpl. Got to know that blocktopmenu.tpl have the same codes repeated for searchbar for top menu. Thanks a lot man. Can I now follow these instructions too? http://www.prestashop.com/forums/topic/248300-solved-put-default-text-in-the-search-bar/?p=1232661 It works! Thanks A Lot! Link to comment Share on other sites More sharing options...
dioniz Posted May 5, 2014 Share Posted May 5, 2014 You are welcome. I think you don't need that from other post. If you put placeholder="your text" in input it should do the work. When you start to type in the field, your text dissapears. Link to comment Share on other sites More sharing options...
Junaid Khawaja Posted May 5, 2014 Author Share Posted May 5, 2014 You are welcome. I think you don't need that from other post. If you put placeholder="your text" in input it should do the work. When you start to type in the field, your text dissapears. Yeah you're right. It's working fine! Link to comment Share on other sites More sharing options...
gr_fenix Posted August 20, 2014 Share Posted August 20, 2014 Hi, I want the search icon but whith this code: <input type="text" placeholder="Yourtext" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> Don't show a submin button Thanks Link to comment Share on other sites More sharing options...
sirDonald Posted September 9, 2014 Share Posted September 9, 2014 Hi, how can I show a translated string as a placeholder? I tried the following: <input type="text" name="search_query" placeholder="{l s='Search'}" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> but it just displays the english version on all languages... Link to comment Share on other sites More sharing options...
dioniz Posted September 9, 2014 Share Posted September 9, 2014 @sirDonald You need to translate it in BO > Localization > Translations Link to comment Share on other sites More sharing options...
sirDonald Posted September 9, 2014 Share Posted September 9, 2014 @sirDonald You need to translate it in BO > Localization > Translations The translation is already there (under Search -> Search = Suche). Sorry should have added that Link to comment Share on other sites More sharing options...
dioniz Posted September 9, 2014 Share Posted September 9, 2014 Are you translating modules? Link to comment Share on other sites More sharing options...
gr_fenix Posted September 9, 2014 Share Posted September 9, 2014 How to show the icon search? Thanks Link to comment Share on other sites More sharing options...
Junaid Khawaja Posted September 9, 2014 Author Share Posted September 9, 2014 How to show the icon search? Thanks It just require few lines of CSS and all done.. Follow this link. http://jsfiddle.net/handtrix/HDmw2/ Link to comment Share on other sites More sharing options...
sirDonald Posted September 10, 2014 Share Posted September 10, 2014 @dioniz No, I just wanted to show a placeholder in the search field of the top menu bar. It should change according to the currently selected language. Under Localization > Translations there already is a translated string for "Search" (probably from the search module? which I have disabled) So I thought I could just use this one. But no matter which language I select, it always just displays "Search", in English. Link to comment Share on other sites More sharing options...
dioniz Posted September 10, 2014 Share Posted September 10, 2014 @sirDonald If you are using search field in top menu bar you need to translate it in Localization > Translations > Installed modules translations. Search for blocktopmenu and translate there Link to comment Share on other sites More sharing options...
sirDonald Posted September 10, 2014 Share Posted September 10, 2014 Didn't think of that, thanks! Is it possible to add new strings? Link to comment Share on other sites More sharing options...
dioniz Posted September 10, 2014 Share Posted September 10, 2014 You can add strings like this in module tpl files: {l s='Some string.' mod='somemodule'} 1 Link to comment Share on other sites More sharing options...
gr_fenix Posted September 29, 2014 Share Posted September 29, 2014 Adding this code on the blocktopmenu.tpl of the theme, it works: <form id="searchbox" method="get" action="{$link->getPageLink('search')|escape:'html':'UTF-8'}" > <input type="hidden" name="controller" value="search" /> <input type="hidden" name="orderby" value="position" /> <input type="hidden" name="orderway" value="desc" /> <input class="search_query form-control" type="text" id="search_query_top" name="search_query" placeholder="{l s='Search' mod='blocksearch'}" value="{$search_query|escape:'htmlall':'UTF-8'|stripslashes}" /> <button type="submit" name="submit_search" class="btn btn-default button-search"> <span>{l s='Search' mod='blocksearch'}</span> </button> </form> Link to comment Share on other sites More sharing options...
upngo Posted January 29, 2015 Share Posted January 29, 2015 Adding this code on the blocktopmenu.tpl of the theme, it works: <form id="searchbox" method="get" action="{$link->getPageLink('search')|escape:'html':'UTF-8'}" > <input type="hidden" name="controller" value="search" /> <input type="hidden" name="orderby" value="position" /> <input type="hidden" name="orderway" value="desc" /> <input class="search_query form-control" type="text" id="search_query_top" name="search_query" placeholder="{l s='Search' mod='blocksearch'}" value="{$search_query|escape:'htmlall':'UTF-8'|stripslashes}" /> <button type="submit" name="submit_search" class="btn btn-default button-search"> <span>{l s='Search' mod='blocksearch'}</span> </button> </form> Hello, i add this code on blocktopmenu.css but don't possible see icon search on my website. store.nyro.es. What is the problem? Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts