Jump to content

Personnaliser le champ du moteur de recherche et traduire le message affiché suivant la langue


Recommended Posts

Bonjour

 

J'ai fait l'intégration du bout de code proposé par Arômes & Gourmandiz dans ce sujet 

http://www.prestashop.com/forums/topic/182473-resolu-personnaliser-le-champ-du-moteur-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 .

<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'}';" />

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.

 

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 :

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 

 

<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üsqueda...' mod='blocksearch'}{/if}" onfocus="if(this.value=='{l s='büsqueda...' mod='blocksearch'}')this.value='';" onblur="if(this.value=='')this.value='{l s='büsqueda...' mod='blocksearch'}';" ';
} 
}
/>

 

Il provoque les erreurs suivantes 

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "
D:\mon-site\themes\theme782\modules\blocksearch\blocksearch-top.tpl" 
on line 62 "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'}';" ';
" unexpected closing tag' in D:\mon-site\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667

SmartyCompilerException: Syntax Error in template "
D:\mon-site\themes\theme782\modules\blocksearch\blocksearch-top.tpl" 
on line 62 "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'}';" ';
" unexpected closing tag in D:\mon-site\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667

Merci de votre aide !!

Edited by reaman (see edit history)
Link to comment
Share on other sites

  • 3 months later...

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...