Jump to content

Comment fait t-on pour récupérer l'id de la langue dans une fonction static??


Recommended Posts

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

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

  • 1 year 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...