Bonjour

J'ai fait l'intégration du bout de code proposé par Arômes & Gourmandiz dans ce sujet
http://www.prestashop.com/forums/top...-de-recherche/

Il nous propose ce code afin de faire apparaître le message "Rechercher..." dans le champ de recherche, ce que je trouve très bien .

Une chose que j'aimerai ajouter c'est la traduction dans les différentes langues que mon site utilisera, (FR, GB, ES) le mot "Rechercher..." qui apparait dans le champ du moteur de recherche afin.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<input class="search_query" type="text" id="search_query_top" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|htmlentities:$ENT_QUOTES:'utf-8'|stripslashes}{else}{l s='Rechercher...' mod='blocksearch'}{/if}" onfocus="if(this.value=='{l s='Rechercher...' mod='blocksearch'}')this.value='';" onblur="if(this.value=='')this.value='{l s='Rechercher...' mod='blocksearch'}';" />
Comme les langues on un id différents comme suit :

FR = id_lang=1
GB = id_lang=4
ES = id_lang=3

Je pourrai faire la condition suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
if ( id_lang == 1 )
 {
   echo "Rechercher..." ;
 } 
elseif (id_lang == 4 ) 
 {
   echo "Search..." ;
 } 
else 
 {
   echo "búsqueda" ;
 }
Mais vue que l'on ne mélange pas le code php et HTML sous prestashop à cause du MVC, je ne sais pas comment réaliser cette condition et afficher la bonne traduction du mot dans la langue....

J'ai essayé ce code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
<input class="search_query" type="text" id="search_query_top" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|htmlentities:$ENT_QUOTES:'utf-8'|stripslashes}{else}{
 
if ( id_lang == 1 )
{
  echo '{l s='Rechercher...' mod='blocksearch'}{/if}" onfocus="if(this.value=='{l s='Rechercher...' mod='blocksearch'}')this.value='';" onblur="if(this.value=='')this.value='{l s='Rechercher...' mod='blocksearch'}';" ';
} 
else if ( id_lang == 4 ) 
{
  echo '{l s='Searsh...' mod='blocksearch'}{/if}" onfocus="if(this.value=='{l s='Search...' mod='blocksearch'}')this.value='';" onblur="if(this.value=='')this.value='{l s='Seach...' mod='blocksearch'}';" ';
} 
else if ( id_lang == 3 )
{
 
   echo '{l s='b&uuml;squeda...' mod='blocksearch'}{/if}" onfocus="if(this.value=='{l s='b&uuml;squeda...' mod='blocksearch'}')this.value='';" onblur="if(this.value=='')this.value='{l s='b&uuml;squeda...' mod='blocksearch'}';" ';
} 
}
/>
Il provoque les erreurs suivantes
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template &quot;
D:\mon-site\themes\theme782\modules\blocksearch\blocksearch-top.tpl&quot;
on line 62 &quot;echo '{l s='b&amp;uuml;squeda...' mod='blocksearch'}{/if}&quot;
onfocus=&quot;if(this.value=='{l s='b&amp;uuml;squeda...' mod='blocksearch'}')this.value='';&quot;
onblur=&quot;if(this.value=='')this.value='{l s='b&amp;uuml;squeda...' mod='blocksearch'}';&quot; ';
&quot; unexpected closing tag' in D:\mon-site\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667

SmartyCompilerException: Syntax Error in template &quot;
D:\mon-site\themes\theme782\modules\blocksearch\blocksearch-top.tpl&quot;
on line 62 &quot;echo '{l s='b&amp;uuml;squeda...' mod='blocksearch'}{/if}&quot;
onfocus=&quot;if(this.value=='{l s='b&amp;uuml;squeda...' mod='blocksearch'}')this.value='';&quot;
onblur=&quot;if(this.value=='')this.value='{l s='b&amp;uuml;squeda...' mod='blocksearch'}';&quot; ';
&quot; unexpected closing tag in D:\mon-site\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667
Merci de votre aide !!