Jump to content

Récupération d'une variable dan un tpl vers un hook


Recommended Posts

Dans product-list.tpl.

{php}
           $data =  $this->_tpl_vars['product']['id_product']; 
           echo $data;
           {/php}



Je récupère bien la variable $data.
Cependant dans un hook que j'ai créer je voudrais que cette variable sois lu.

{$HOOK_CATEGORY_LIST}

Voilà le modèle du hook que j'ai créer :

   function hookCategoryList($params)
   {
       global $smarty, $cookie, $data;

            echo $data .'
';
       $idProduct = intval($data);

       $product = new Product(intval($idProduct), false, intval($cookie->id_lang));

....

       return $this->display(__FILE__, 'combinaison.tpl');
}



Je voudrait récupérer l'id du tpl dans mon hook.

Link to comment
Share on other sites

Je pense que tu mélanges les intérêts réels de l'usage du php depuis smarty (à éviter au passage), et aussi l'appel à des fonctions.

Pourquoi ne pas traiter ta variable depuis un

$smarty->register_function('fonction_In_tpl', 'fonction_In_php);



A+

Link to comment
Share on other sites

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