romelik Posted January 8, 2016 Share Posted January 8, 2016 (edited) Bonjour J'ai modifié un module en ajoutant une variable dans mon fichier monModule.php Je parviens à récupérer ma variabledans monModule.tpl grâce à {$maVariable} mais j'aimerai également récupérer cette variable dans header.tpl et là je bloque!! Je cherche, je cherche ... sûrement au mauvais endroit mais je n'y arrive pas ... Dans monModule.php J'ai ajouté ceci pour créer ma variable : public $maVariable = 'test variable' public function hookHeader() { global $smarty; $this->smarty->assign('maVariable',$this->maVariable); } Dans monModule.tpl lorsque j'appelle {$maVariable} cela m'affiche bien ' test variable ' Comment faire pour y avoir également accès dans header.tpl?? D'avance merci à vous ... Edited January 9, 2016 by romelik (see edit history) Link to comment Share on other sites More sharing options...
coeos.pro Posted January 8, 2016 Share Posted January 8, 2016 ce n'est pas possible si le tpl du module est traité après le header.tpl. MAIS tu peux créer un hook dans ton header, ou utiliser un hook déjà présent comme HOOK_HEADER pour y envoyer ta variable. Link to comment Share on other sites More sharing options...
romelik Posted January 8, 2016 Author Share Posted January 8, 2016 effectivement monModule vient juste après mon header c'est un module TopMenu ... donc je pensais bien que c'était la cause ... peux-tu être plus précis dans la marche à suivre pour envoyer ma variable dans HOOK_HEADER s'il te plaît ?? Link to comment Share on other sites More sharing options...
coeos.pro Posted January 8, 2016 Share Posted January 8, 2016 tu rajoutes dans ton module : public function hookHeader() { $this->context->smarty->assign('maVariable',$this->maVariable); } et tu le greffes sur le hook hookHeader Link to comment Share on other sites More sharing options...
romelik Posted January 8, 2016 Author Share Posted January 8, 2016 Désolé j'suis pas super au point mais ...comment je greffe sur le hook hookHeader??? Link to comment Share on other sites More sharing options...
romelik Posted January 8, 2016 Author Share Posted January 8, 2016 Tu veux dire que je greffe mon module ??? Link to comment Share on other sites More sharing options...
coeos.pro Posted January 8, 2016 Share Posted January 8, 2016 dans modules > positions, clique en haut à droite sur "greffer un module" Link to comment Share on other sites More sharing options...
romelik Posted January 8, 2016 Author Share Posted January 8, 2016 Mon module est déjà greffé dans le displayHeader ... mais je ne vois pas de Hookheader ... même en cochant " afficher les points d'accroche invisible " je suis en version 1.6.1.2. Link to comment Share on other sites More sharing options...
romelik Posted January 8, 2016 Author Share Posted January 8, 2016 YES!!! Merci beaucoup cela fonctionne !!! Peux-tu m'expliquer cette ligne : " return $this->display(__FILE__, 'header.tpl'); " Que je comprenne pour une prochaine fois ... Merci encore Link to comment Share on other sites More sharing options...
coeos.pro Posted January 8, 2016 Share Posted January 8, 2016 c'est pour utiliser le fichier header.tpl Link to comment Share on other sites More sharing options...
romelik Posted January 8, 2016 Author Share Posted January 8, 2016 Merci encore !!! 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