NewDevOnPrest Posted February 9, 2022 Share Posted February 9, 2022 (edited) Hello, I am a beginner in Prestashop 1.7.8 and I try to create a link in the side menu of the back office in order to arrive on a new page. I followed the documentation but it doesn't work. My module is recognized and installed. Any idea why my code isn't working? class Gaston extends Module { public function __construct() { $this->tabs = [ 'name' => 'Gaston', 'visible' => true ]; $this->name = 'Gaston'; //... } Edited February 9, 2022 by NewDevOnPrest (see edit history) Link to comment Share on other sites More sharing options...
knacky Posted February 10, 2022 Share Posted February 10, 2022 (edited) If someone followed the documentation, it would work. I don't see parent_class_name in your cut code. Best of all, turn on debug mode and follow the errors. https://devdocs.prestashop.com/1.7/modules/concepts/controllers/admin-controllers/tabs/ Edited February 10, 2022 by knacky (see edit history) Link to comment Share on other sites More sharing options...
NewDevOnPrest Posted February 10, 2022 Author Share Posted February 10, 2022 (edited) Thanks for your help knacky, I followed the doc. I just forgot to target the controller. My module class Gaston extends Module { public function __construct() { $this->tabs = [ 'name' => 'Gaston', 'class_name' => 'Gaston', 'visible' => true ]; $this->name = 'Gaston'; //... } My Controller class GastonController extends FrameworkBundleAdminController { //... } Edited February 10, 2022 by NewDevOnPrest (see edit history) Link to comment Share on other sites More sharing options...
knacky Posted February 11, 2022 Share Posted February 11, 2022 <?php use Language; class Example_module_mailtheme extends Module { public function install() { return parent::install() && $this->installTab() ; } public function uninstall() { return parent::uninstall() && $this->uninstallTab() ; } public function enable($force_all = false) { return parent::enable($force_all) && $this->installTab() ; } public function disable($force_all = false) { return parent::disable($force_all) && $this->uninstallTab() ; } private function installTab() { $tabId = (int) Tab::getIdFromClassName('MyModuleDemoController'); if (!$tabId) { $tabId = null; } $tab = new Tab($tabId); $tab->active = 1; $tab->class_name = 'MyModuleDemoController'; // Only since 1.7.7, you can define a route name $tab->route_name = 'admin_my_symfony_routing'; $tab->name = array(); foreach (Language::getLanguages() as $lang) { $tab->name[$lang['id_lang']] = $this->trans('My Module Demo', array(), 'Modules.MyModule.Admin', $lang['locale']); } $tab->id_parent = (int) Tab::getIdFromClassName('ShopParameters'); $tab->module = $this->name; return $tab->save(); } private function uninstallTab() { $tabId = (int) Tab::getIdFromClassName('MyModuleDemoController'); if (!$tabId) { return true; } $tab = new Tab($tabId); return $tab->delete(); } } Link to comment Share on other sites More sharing options...
NewDevOnPrest Posted February 20, 2022 Author Share Posted February 20, 2022 Thanks Knacky! 1 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