andy durbecq Posted May 10, 2012 Share Posted May 10, 2012 Bonjour, je viens de suivre le Guide du développeur section crééer un module et a un moment il nous font passer une variable au template via l'assignation à smarty. Hors même en suivant les indication la traduction de la variable passé du fichier mymodule_page.php à mymodule_page.tpl ne veut pas se traduire et pourtant j'ai bien rempli sa traduction dans le back. mymodule_page.php <?php global $smarty; include('../../config/config.inc.php'); include('../../header.php'); $mymodul = new MyModule(); $smarty->assign('messageSmarty', $mymodul->l('Welcome toto')); // creation of our variable $smarty->display(dirname(__FILE__).'/mymodule_page.tpl'); include( '../../footer.php' ); ?> mymodule_page.tpl {$messageSmarty} Quelqu'un pourrait-il m'éclairer. PS : Si vous avez de bon tuto pour apprendre Prestashop je suis preneur. Link to comment Share on other sites More sharing options...
andy durbecq Posted May 15, 2012 Author Share Posted May 15, 2012 Personne !!! Tanpis Link to comment Share on other sites More sharing options...
belew Posted May 15, 2012 Share Posted May 15, 2012 (edited) Commet ça tu as remplis la traduction dans le back ? Il faut que tu crée un fichier fr.xml pour la langue Française et crypter "Welcome toto" en MD5 pour avoir sa traduction. Sers toi d'un exemple sur un autre module natif tu comprendras ++ Edited May 15, 2012 by belew (see edit history) Link to comment Share on other sites More sharing options...
andy durbecq Posted May 15, 2012 Author Share Posted May 15, 2012 Merci pour ta réponse. En effet j'ai été dans l'onglet traduction du back et j'ai pu traduire mon texte directement. Ce qui a généré le fichier xml. Cependant si dans le fichier tpl je met directement {l s='Welcome toto!' mod='mymodule'} Sa marche mais en passant par une variable cela ne marche pas ??? Pourtant j'ai bien suivi le guide du développeur : http://doc.prestashop.com/pages/viewpage.action?pageId=3801216 Link to comment Share on other sites More sharing options...
belew Posted May 16, 2012 Share Posted May 16, 2012 Salut, Tu fais bien $this->l('Welcome toto'); Link to comment Share on other sites More sharing options...
andy durbecq Posted May 16, 2012 Author Share Posted May 16, 2012 <?php global $smarty; include('../../config/config.inc.php'); include('../../header.php'); $mymodul = new MyModule(); $smarty->assign('messageSmarty', $mymodul->l('Welcome toto')); // creation of our variable $smarty->display(dirname(__FILE__).'/mymodule_page.tpl'); include( '../../footer.php' ); ?> En effet après avoir créé l'objet module ($mymodul) je fais un $mymodul->l('Welcome toto'). Link to comment Share on other sites More sharing options...
belew Posted May 17, 2012 Share Posted May 17, 2012 (edited) Salut, Fais un Tools:: d($mymodul) (Equivalent var_dump mais pour le framework prestashop) pour voir s'il l'objet est bien instancié et voir s'il te renvois bien une valeur, Fait le également pour la variable $smarty. Est ce que mymodule_page.php est ton controller (fichier PHP principal du module) ? Sinon envoie moi l'arborescence de tes fichiers. Edited May 17, 2012 by belew (see edit history) Link to comment Share on other sites More sharing options...
andy durbecq Posted May 18, 2012 Author Share Posted May 18, 2012 Salut, En faite comme je débute sur prestashop je me suis dit que de suivre les exemples du guide du dev me permettrait de comprendre un peu les modules prestashop. J'ai donc créé dans le dossier modules l'arbo suivante : mymodule/ - mymoduke.php (Class qui hérite de module) - mymodule.tpl - mymodule_page.php (autre fichier appelé directement via l'url http://www.exemple.com/modules/mymodule/mymodule_page.php) - mymodule_page.tpl Link to comment Share on other sites More sharing options...
belew Posted May 18, 2012 Share Posted May 18, 2012 Déja si tu es sur un fichier autre que ton fichier principal c'est a dire le CONTROLLER du module appelle la classe de ton module include('../mymodule.php'); Mais pour ce qui est des assignations en smarty je te conseille de tout faire dans ton fichier mymodule.php ainsi tu pourras acceder a la méthode $this->l(''); ++ Link to comment Share on other sites More sharing options...
andy durbecq Posted May 18, 2012 Author Share Posted May 18, 2012 Merci pour ta réponse et le temps que tu y a accordé Je vais faire comme tu me l'as dit. PS : Si tu connais de bon tutos sérieux je suis preneur ! Link to comment Share on other sites More sharing options...
belew Posted May 18, 2012 Share Posted May 18, 2012 Avec plaisir ! Le tutos que tu suis est selon moi le meilleur il fait partie de la documentation prestashop officielle donc tu trouveras pas mieux ++ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now