Webotool Posted July 5, 2017 Share Posted July 5, 2017 Bonjour, Je suis entrain de suivre le « Debeloper Guide » sur la création de module mais je n’arrive pas à lier de CSS. A l’étape « Displaying content on the front office » apres avoir créé template et un css, j’ajoute une méthode hookDisplayHeader mais rien n’y fait… Help Voici la structure des fichiers Le code class BelgaModule extends Module { public function __construct() { $this->name = 'belgamodule'; // technical name $this->tab = 'front_office_features'; $this->version = '0.1'; $this->author = "BELGA Dam'z"; parent::__construct(); $this->displayName = $this->l('Belga Module'); // public name $this->description = $this->l('Premier module de laboratoire.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstal?'); if (!Configuration::get('MYMODULE_NAME')) $this->warning = $this->l('No name provide.'); } public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); return parent::install() && $this->registerHook('hookDisplayHeader') && $this->registerHook('leftColumn') && $this->registerHook('header') && Configuration::updateValue('MYMODULE_NAME', 'BelgaWeb Module'); } public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('MYMODULE_NAME')) return false; return true; } public function hookDisplayLeftColumn($params) { $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'my_module_link' => $this->context->link->getModuleLink('belgamodule', 'display') ) ); return $this->display(__FILE__, 'belgamodule.tpl'); } public function hookDisplayRightColumn($params) { return $this->hookDisplayLeftColumn($params); } public function hookDisplayHeader() { $this->context->controller->addCSS($this->_path.'css/belgamodule.css', 'all'); } public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $module_name = strval(Tools::getValue('MYMODULE_NAME')); if (!$module_name || empty($module_name) || !Validate::isGenericName($module_name)) { $output .= $this->displayError($this->l('Invalid Configuration value')); } else { Configuration::updateValue('MYMODULE_NAME', $module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->displayForm(); } public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array('title' => $this->l('Settings'), ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Configuration value'), 'name' => 'MYMODULE_NAME', 'size' => 20, 'required' => true ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default pull-right' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; //requires the instance of the module that will use the form $helper->name_controller = $this->name; // reuires the name of the module $helper->token = Tools::getAdminTokenLite('AdminModules'); // requires a unique token for the module $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; // Title form $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes -> Toolbar is always visible on the top of the screen $helper->submit_action = 'submit'.$this->name; // requires the action attribute $helper->toolbar_btn = array( // requires the btn that are display in the toolbar(Save & Back) 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'$configure='.$this->name. '$save'.$this->name. '$token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'$token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['MYMODULE_NAME'] = Configuration::get('MYMODULE_NAME'); // Valeur of the named tag return $helper->generateForm($fields_form); } } Merci Link to comment Share on other sites More sharing options...
Matt K. Posted July 6, 2017 Share Posted July 6, 2017 Bonjour, Tu passes bien dans la fonction hookDisplayHeader ? Ton CSS est dans quel répertoire ? Link to comment Share on other sites More sharing options...
Webotool Posted July 7, 2017 Author Share Posted July 7, 2017 (edited) Bonjour, Le CSS est dans belgamodule \ css \ belgamodule.css J'ai une fonction hookDisplayHeader() public function hookDisplayHeader() { $this->context->controller->addCSS($this->_path.'css/belgamodule.css', 'all'); } Et un registerHook dans la fonction install() public function install() { return parent::install() && $this->registerHook('displayHeader') && $this->registerHook('leftColumn') && $this->registerHook('header') && Configuration::updateValue('MYMODULE_NAME', 'BelgaWeb Module'); } Voila, merci pour l'aide Edited July 7, 2017 by BelgaWeb (see edit history) Link to comment Share on other sites More sharing options...
Matt K. Posted July 7, 2017 Share Posted July 7, 2017 Merci, Ton cache est activé ou pas ? Tu as essayé de la vider ? Link to comment Share on other sites More sharing options...
Webotool Posted July 7, 2017 Author Share Posted July 7, 2017 (edited) Le cache est déactiver et il a été vider quelque fois mais rien n'y fait...La compilation est forcé à chaque appel aussi. Edited July 7, 2017 by BelgaWeb (see edit history) Link to comment Share on other sites More sharing options...
Matt K. Posted July 7, 2017 Share Posted July 7, 2017 Si tu met un gros die; dans ton hook tu as une page blanche ? Link to comment Share on other sites More sharing options...
olishop Posted July 7, 2017 Share Posted July 7, 2017 et si tu met ton $this->context->controller->addCSS($this->_path.'css/belgamodule.css', 'all'); juste avant le return $output.$this->displayForm(); dans la fonction 'getContent()' cela fonctionne ou pas ? Link to comment Share on other sites More sharing options...
Webotool Posted July 7, 2017 Author Share Posted July 7, 2017 Merci pour votre aide Mais l'erreur venait du fait que j'ai oublier le return dans la fonction displayHeader() 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