mwane Posted May 3, 2011 Share Posted May 3, 2011 Bonjour maxime, je suis dans cette fonction :-----------------------------------------------------------static public function getByProduct($id_product, $p = 1, $n = null) { if (!Validate::isUnsignedId($id_product)) die(Tools::displayError()); $validate = Configuration::get('PRODUCT_COMMENTS_MODERATE'); $p = intval($p); $n = intval($n); if ($p <= 1) $p = 1; if ($n != null AND $n <= 0) $n = 5; if(intval($cookie->id_lang) == 0 || intval($cookie->id_lang)== NULL) { $id_langP = Configuration::get('PS_LANG_DEFAULT'); } else { $id_langP = intval($cookie->id_lang); } $id_langP = intval($cookie->id_lang); ----------------------------------------------------------------Comment fait t-on pour récupérer l'id de la langue dans une fonction statique : voici ce que j'ai fais dans la fonction: if(intval($cookie->id_lang) == 0 || intval($cookie->id_lang)== NULL) { $id_langP = Configuration::get('PS_LANG_DEFAULT'); } else { $id_langP = intval($cookie->id_lang); }Mais $id_langP retourne toujours la valeur zéro. Link to comment Share on other sites More sharing options...
Vincent Decaux Posted May 3, 2011 Share Posted May 3, 2011 Bon j'aide un peu niveau lecture : static public function getByProduct($id_product, $p = 1, $n = null) { if (!Validate::isUnsignedId($id_product)) die(Tools::displayError()); $validate = Configuration::get(‘PRODUCT_COMMENTS_MODERATE’); $p = intval($p); $n = intval($n); if ($p <= 1) $p = 1; if ($n != null AND $n <= 0) $n = 5; if(intval($cookie->id_lang) 0 || intval($cookie->id_lang) NULL) { $id_langP = Configuration::get(‘PS_LANG_DEFAULT’); } else { $id_langP = intval($cookie->id_lang); } $id_langP = intval($cookie->id_lang); Il faut appeler la variable globale $cookie au début de ta fonction : static public function getByProduct($id_product, $p = 1, $n = null) { global $cookie; A essayer... Link to comment Share on other sites More sharing options...
mwane Posted May 4, 2011 Author Share Posted May 4, 2011 ok, ça marcheMERCI Link to comment Share on other sites More sharing options...
scoobi Posted February 2, 2013 Share Posted February 2, 2013 Merci Vincent Decaux ! Cela m'a été très utile 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