webmatersweetch Posted May 15, 2019 Share Posted May 15, 2019 Bonsoir ! Je suis bloqué sur un point depuis 2 jours.. Pouvez-vous m'aider ? Voici mon problème, j'aimerai afficher du contenu depuis ma BDD dans une Tab crée à partir de mon module. Voici mon code class AdminMontesController extends ModuleAdminController { public function __construct(){ $this->table = 'montes'; $this->className = 'Montes'; $this->bootstrap = true; $this->fields_list = array( 'id_montes' => array('title'=>'ID','align'=>'left','width'=>50) ); $this->addRowAction('view'); parent::__construct(); } public function renderView(){ $tpl = $this->context->smarty->createTemplate(dirname(__FILE__).'\..\..\views\templates\admin\view.tpl'); $tpl->assign('montes',$this->object); return $tpl->fetch(); } } Dans mon tpl, mon $this->object ne fonctionne pas et je ne comprend pas pourquoi <h1>{$montes->id_montes}</h1> id_montes étant un champ BDD. Ma class Core étant bien class Montes extends Module Voici l'erreur : Notice: Undefined property: Montes::$id_montes Quelqu'un aurait-il une réponse ? Merci Link to comment Share on other sites More sharing options...
Eolia Posted May 15, 2019 Share Posted May 15, 2019 Et qu'y a t il dans la définition de votre classe (le début de votre fichier) ? Link to comment Share on other sites More sharing options...
webmatersweetch Posted May 15, 2019 Author Share Posted May 15, 2019 Merci pour cette rapide réponse ! Voici ma class core Module <?php /** * */ class Montes extends Module { public function __construct() { $this->displayName = 'Montes'; $this->name = 'montes'; $this->description = 'Montes'; $this->author = 'Montes'; $this->version = '1.0'; $this->bootstrap = true; parent::__construct(); } public function install(){ if (!parent::install()) { return false; } if (!$this->installDB()) { return false; } if (!$this->installTab('AdminCatalog','AdminMontes','Montes')) { return false; } return true; } public function uninstall(){ if (!parent::uninstall()) { return false; } if (!$this->unintallTab('AdminMontes')) { return false; } return true; } private function installDB(){ return ( Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'montes`') && Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'montes` ( `id_montes` int(10) NOT NULL AUTO_INCREMENT, `montes` int(10) NOT NULL, PRIMARY KEY (`id_montes`) ) ENGINE = '._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;') ); } public function getContent(){ } public function installTab($parent, $class_name, $name){ $tab = new Tab(); $tab->id_parent = (int)Tab::getIdFromCLassName($parent); $tab->name = array(); foreach (Language::getLanguages(true) as $lang) { $tab->name[$lang['id_lang']] = $name; } $tab->class_name = $class_name; $tab->module = $this->name; $tab->active = 1; return $tab->add(); } public function unintallTab($class_name){ $id_tab = (int)Tab::getIdFromCLassName($class_name); $tab = new Tab($id_tab); return $tab->delete(); } } Link to comment Share on other sites More sharing options...
Eolia Posted May 15, 2019 Share Posted May 15, 2019 Ok donc $id_montes n'est jamais défini... Vous utilisez un objet $montes qui n'existe pas (enfin si, c'est la classe de votre module mais qui ne correspond pas à ce que vous voulez faire) Vous devez avoir: - l'objet module - l'objet montes avec ses propriétés d'autre part (l'objet et le module ne peuvent pas avoir le même nom) 1 Link to comment Share on other sites More sharing options...
webmatersweetch Posted May 15, 2019 Author Share Posted May 15, 2019 Mais mince oui ! Défois faut vraiment prendre du recul et juste ce poser les bonnes questions du pourquoi du comment ! Merci Eolia, toujours présent pour répondre rapidement et efficacement ! 😀 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