harish.m Posted April 7, 2018 Share Posted April 7, 2018 (edited) I am trying to add module configuration page to backoffice sidebar menu we have added this installTab function to add menu in sidebar but having error in creating 3rd menu configuration in sidebar . I got the token mismatch error . public function installTab() { $languages = Language::getLanguages(false); $tab = new Tab(); $name = array(); foreach ($languages as $lang) { $name[$lang['id_lang']] = $this->l('Competition'); } $tab->name = $name; $tab->module = $this->name; if (version_compare(_PS_VERSION_, '1.7.0', '>=') === true) { $tab->id_parent = 2; } $tab->class_name = 'COMPETITION'; $tab->save(); Db::getInstance()->execute( ' UPDATE `'._DB_PREFIX_.'tab` t SET position = 5 WHERE id_tab = '.(int)$tab->id ); $tab->cleanPositions(0); $tab1 = new Tab(); $name = array(); foreach ($languages as $lang) { $name[$lang['id_lang']] = $this->l('Products'); } $tab1->name = $name; $tab1->module = $this->name; $tab1->class_name = 'AdminProductCompare'; $tab1->id_parent = (int)$tab->id; $tab1->save(); $tab2 = new Tab(); $name = array(); foreach ($languages as $lang) { $name[$lang['id_lang']] = $this->l('Settings'); } $tab2->name = $name; $tab2->class_name = 'AdminModules&configure=moduleclassname'; $tab2->id_parent = (int)$tab->id; $tab2->save(); } Edited April 7, 2018 by harish.m security (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted April 7, 2018 Share Posted April 7, 2018 This property is wrong$tab2->class_name = 'AdminModules&configure=moduleclassname'; It should be the name of the class of the actual file that displays the view Link to comment Share on other sites More sharing options...
vividusdesigns Posted June 10, 2019 Share Posted June 10, 2019 (edited) For anyone else looking for the solution try this: create a admin controller than link tab to controller and than add redirect to configure page: public function __construct() { parent::__construct(); } public function initContent() { $configure = $this->context->link->getAdminLink('AdminModules', false) .'&configure='.$this->module->name.'&tab_module='.$this->module->tab.'&module_name='.$this->module- >name.'&token='.Tools::getAdminTokenLite('AdminModules'); Tools::redirectAdmin($configure); die(); } Edited June 10, 2019 by vividusdesigns (see edit history) 1 Link to comment Share on other sites More sharing options...
jackieyap79 Posted January 21, 2020 Share Posted January 21, 2020 On 6/10/2019 at 9:14 PM, vividusdesigns said: For anyone else looking for the solution try this: create a admin controller than link tab to controller and than add redirect to configure page: public function __construct() { parent::__construct(); } public function initContent() { $configure = $this->context->link->getAdminLink('AdminModules', false) .'&configure='.$this->module->name.'&tab_module='.$this->module->tab.'&module_name='.$this->module- >name.'&token='.Tools::getAdminTokenLite('AdminModules'); Tools::redirectAdmin($configure); die(); } Hi Vividusdesigns, thank you to your kindness on the solution, do you mind to explain a little bit on the step? 1. How to Create Admin controller? 2. How to link tab to controller? 3. How to add redirect to configure page? Thank you in advance. 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