daftfunk Posted May 15, 2012 Share Posted May 15, 2012 Salut a tous! je cherche à faire un truc tout simple mais qui étant donné mon niveau en POO se revele un réel casse tête - j'en appelle donc à votre noblesse d'esprit pour qu'a partir de ce cas pratique je puisse comprendre comment implémenter certaines fonctions dans mes pages. Alors voila, je cherche à afficher la valeur (en %) de réduction sur la page product_list (quant naturellement le produit est en promo). actuellement ce % apparaît que sur la page product . - dans la page product, on appelle la réduction comme ca {$product->specificPrice.reduction*100} ce qui ne fonctionne pas dans product_list J'ai donc décider de récupéré la valeur en passant par la class Product j'ai donc cree un nouvel attribut public $prom= 0; et un fonction chargée d'aller récupérer l'info voulue protected function prompercent() { $resultprom = Db::getInstance()->getValue('SELECT `reduction` FROM `'._DB_PREFIX_.'specific_price` WHERE `id_product` = '.(int)($this->id)); $prom=$resultprom; return $prom; } Puis dans mon template j'appelle ma fonction {$product->prompercent()} Bref ça marche pas bien bien en fait... mas question c'est pourquoi!? Merci pour votre patience Link to comment Share on other sites More sharing options...
IchabOd Posted May 15, 2012 Share Posted May 15, 2012 il faut appeler la fonction depuis le controller et assigner la variable à smarty depuis le controller. Link to comment Share on other sites More sharing options...
daftfunk Posted May 16, 2012 Author Share Posted May 16, 2012 (edited) ???!!?? ... tu me parles chinois !! dans les faits ça donne quoi? et surtout pourquoi? merci pour ton temps ... entre temps j'ai trouvé les pages dit "controller" mais grosso modo la class est appeller via le controller ... l'interet? Edited May 16, 2012 by daftfunk (see edit history) 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