soundhar Posted June 5, 2019 Share Posted June 5, 2019 (edited) Hi everyone, I am trying to create a custom module admin menu. I need one parent and multiple child menus. Inspiraiton Wall Background Frames Frames Images Menu4 etc., I have used tabs registration. that works for 1 parent and 1 child. Module name : inspiration The following code generate Inspiraiton Wall Background But I am expecting the Inspiraiton Wall Background Frames Please tell me how to fix this. Thanks to all $lang = Language::getLanguages(); $tab = new Tab(); $tab->class_name = 'AdminExample'; $tab->module = 'inspiration'; $tab->id_parent = 2; $tab->position = 6; $tab->icon = 'photo_size_select_actual'; $tab->parent_class_name = 'AdminExample'; foreach ($lang as $l) { $tab->name[$l['id_lang']] = $this->l('Inspiration'); } $tab->add(); $tab = new Tab(); $tab->active = 1; $tab->class_name = 'AdminExample'; $tab->name = array(); foreach (Language::getLanguages(true) as $lang) { $tab->name[$lang['id_lang']] = "Wall Background"; } $tab->id_parent = (int)Tab::getIdFromClassName('AdminExample'); $tab->module = $this->name; $tab->add(); $tab = new Tab(); $tab->active = 1; $tab->class_name = 'AdminFrames'; $tab->name = array(); foreach (Language::getLanguages(true) as $lang) { $tab->name[$lang['id_lang']] = "Frames"; } $tab->id_parent = (int)Tab::getIdFromClassName('AdminFrames'); $tab->module = $this->name; $tab->add(); Edited June 5, 2019 by soundhar (see edit history) Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted June 6, 2019 Share Posted June 6, 2019 Hi.... try this $languages = Language::getLanguages(false); //Main Parent menu if (!(int) Tab::getIdFromClassName('AdminInspiration')) { $parentTab = new Tab(); $parentTab->active = 1; $parentTab->name = array(); $parentTab->class_name = "AdminInspiration"; foreach ($languages as $language) { $parentTab->name[$language['id_lang']] = 'Inspiration'; } $parentTab->id_parent = 0; $parentTab->module = ''; $parentTab->add(); } //Sub menu code if (!(int) Tab::getIdFromClassName('AdminWallBackground')) { $parentTabID = Tab::getIdFromClassName('AdminInspiration'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminWallBackground"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Wall Background'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } if (!(int) Tab::getIdFromClassName('AdminFrames')) { $parentTabID = Tab::getIdFromClassName('AdminInspiration'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminFrames"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Frames'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } Thanks 1 Link to comment Share on other sites More sharing options...
soundhar Posted June 11, 2019 Author Share Posted June 11, 2019 (edited) Hi Nishith, Sorry for the late reply. Your solution works great! Thank you so much for that. But is there any option to move the menu to top after SELL? I am working on the module menu pages. I have one issue. I searched about it but could not find any solution. I am trying to create default bootstrap style admin panel. When install the module. I set the bootstrap to true. but when i create the menu pages. I see nobootstrap class added to the id content. please check the screenshots. $this->name = 'inspiration'; $this->tab = 'administration'; $this->version = '1.0.0'; $this->author = 'soundhar'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Gallery Inspiration'); $this->description = $this->l('This module allows create customers own gallery.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); frames.tpl <div class="row"> <div class="col-lg-12"> <div class="panel"> <h1>test</h1> </div> </div> </div> Frames Menu Page Frames Menu Code so if manually replace nobootstrap to bootstrap it works as i expected. is there any solution to remove the nobootstrap class? Thanks a lot Edited June 11, 2019 by soundhar added images (see edit history) Link to comment Share on other sites More sharing options...
soundhar Posted June 11, 2019 Author Share Posted June 11, 2019 Hi I added the following code, after that bootstrap classes is loaded. is that correct way to do that? public function init() { $this->context->controller->addJquery(); $this->context->controller->bootstrap=true; parent::init(); } Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted June 11, 2019 Share Posted June 11, 2019 hi.. Sorry i am not understand where you have added that code ? Thanks Link to comment Share on other sites More sharing options...
soundhar Posted June 11, 2019 Author Share Posted June 11, 2019 On 6/6/2019 at 10:42 AM, Nishith said: Hi.... try this $languages = Language::getLanguages(false); //Main Parent menu if (!(int) Tab::getIdFromClassName('AdminInspiration')) { $parentTab = new Tab(); $parentTab->active = 1; $parentTab->name = array(); $parentTab->class_name = "AdminInspiration"; foreach ($languages as $language) { $parentTab->name[$language['id_lang']] = 'Inspiration'; } $parentTab->id_parent = 0; $parentTab->module = ''; $parentTab->add(); } //Sub menu code if (!(int) Tab::getIdFromClassName('AdminWallBackground')) { $parentTabID = Tab::getIdFromClassName('AdminInspiration'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminWallBackground"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Wall Background'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } if (!(int) Tab::getIdFromClassName('AdminFrames')) { $parentTabID = Tab::getIdFromClassName('AdminInspiration'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminFrames"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Frames'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } Thanks Hi, I added the reply to you but its in hidden status. I don't know where to enable to it. Admin will verify the post if we add any images? Your solution works great! Thank you so much for that. But is there any option to move the menu to top after SELL? Link to comment Share on other sites More sharing options...
soundhar Posted June 11, 2019 Author Share Posted June 11, 2019 Hi Nishith, Sorry for the late reply. Your solution works great! Thank you so much for that. But is there any option to move the menu to top after SELL? https://ibb.co/mNhQGqS Link to comment Share on other sites More sharing options...
phinq1910 Posted June 11, 2019 Share Posted June 11, 2019 try $parentTab->id_parent = ; Link to comment Share on other sites More sharing options...
CedCommerce Team Posted June 21, 2019 Share Posted June 21, 2019 On 6/11/2019 at 12:17 PM, soundhar said: But is there any option to move the menu to top after SELL? Hi, Replace $parentTab->id_parent = 0; with $parentTab->id_parent = (int)Tab::getIdFromClassName('SELL'); Thanks Link to comment Share on other sites More sharing options...
franklin_mbf2 Posted June 30, 2019 Share Posted June 30, 2019 On 6/6/2019 at 2:12 AM, Nishith said: Hi.... try this $languages = Language::getLanguages(false); //Main Parent menu if (!(int) Tab::getIdFromClassName('AdminInspiration')) { $parentTab = new Tab(); $parentTab->active = 1; $parentTab->name = array(); $parentTab->class_name = "AdminInspiration"; foreach ($languages as $language) { $parentTab->name[$language['id_lang']] = 'Inspiration'; } $parentTab->id_parent = 0; $parentTab->module = ''; $parentTab->add(); } //Sub menu code if (!(int) Tab::getIdFromClassName('AdminWallBackground')) { $parentTabID = Tab::getIdFromClassName('AdminInspiration'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminWallBackground"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Wall Background'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } if (!(int) Tab::getIdFromClassName('AdminFrames')) { $parentTabID = Tab::getIdFromClassName('AdminInspiration'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminFrames"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Frames'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } Thanks Hi, i'm new on prestashop development, what file do you put this code in? I'm trying to put ps_imageslider and ps_banner on menu. Any help will be appreciated... Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted July 1, 2019 Share Posted July 1, 2019 7 hours ago, franklin_mbf2 said: Hi, i'm new on prestashop development, what file do you put this code in? I'm trying to put ps_imageslider and ps_banner on menu. Any help will be appreciated... this code put inside module install method Thanks Link to comment Share on other sites More sharing options...
pawelszulc Posted October 17, 2019 Share Posted October 17, 2019 Hi @Nishith , please tell mi if I want to have this structure: Module sub-menu1 sub-menu2 How many admin controller I must create ? Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted October 18, 2019 Share Posted October 18, 2019 Hi @pawelszulc You need create each admin controller foe every sub menu If you need 2 submenu then you need to create 2 admin controller. Thanks Link to comment Share on other sites More sharing options...
preshtaexpert Posted October 18, 2019 Share Posted October 18, 2019 Yes need to assign parent tab menu Like This private function _createTab() { $response = true; // First check for parent tab $parentTabID = Tab::getIdFromClassName('AdminStMenu'); if ($parentTabID) { $parentTab = new Tab($parentTabID); } else { $parentTab = new Tab(); $parentTab->active = 1; $parentTab->name = array(); $parentTab->class_name = "AdminStMenu"; foreach (Language::getLanguages() as $lang){ $parentTab->name[$lang['id_lang']] = "SpacingTech"; } $parentTab->id_parent = 0; $parentTab->module = $this->name; $response &= $parentTab->add(); } // Check for parent tab2 $parentTab_2ID = Tab::getIdFromClassName('AdminStMenu2'); if ($parentTab_2ID) { $parentTab_2 = new Tab($parentTab_2ID); } else { $parentTab_2 = new Tab(); $parentTab_2->active = 1; $parentTab_2->name = array(); $parentTab_2->class_name = "AdminStMenu2"; foreach (Language::getLanguages() as $lang) { $parentTab_2->name[$lang['id_lang']] = "SpacingTech Theme Configure"; } $parentTab_2->id_parent = $parentTab_2->id; $parentTab_2->module = $this->name; $response &= $parentTab_2->add(); } // Created tab $tab = new Tab(); $tab->active = 1; $tab->class_name = "Adminstmegamenu"; $tab->name = array(); foreach (Language::getLanguages() as $lang){ $tab->name[$lang['id_lang']] = "Configure Megamenu"; } $tab->id_parent = $parentTab_2->id; $tab->module = $this->name; $response &= $tab->add(); return $response; } For Live Demos You can check our demo URL https://preshtaexpert.com/oro-landing/ Link to comment Share on other sites More sharing options...
pawelszulc Posted October 18, 2019 Share Posted October 18, 2019 (edited) 2 hours ago, Nishith said: Hi @pawelszulc You need create each admin controller foe every sub menu If you need 2 submenu then you need to create 2 admin controller. Thanks Ok, but the parent tab is not clickable , and my questions is -> do I have to create admin controller for parent tab ? Edited October 18, 2019 by pawelszulc (see edit history) Link to comment Share on other sites More sharing options...
pawelszulc Posted October 18, 2019 Share Posted October 18, 2019 (edited) Hi @Nishith why create a controller for prarent tab if is not clickable ? Edited October 18, 2019 by pawelszulc (see edit history) Link to comment Share on other sites More sharing options...
phinq1910 Posted October 18, 2019 Share Posted October 18, 2019 4 hours ago, pawelszulc said: Ok, but the parent tab is not clickable , and my questions is -> do I have to create admin controller for parent tab ? The parent link will auto get first child link Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted October 18, 2019 Share Posted October 18, 2019 5 hours ago, pawelszulc said: Hi @Nishith why create a controller for prarent tab if is not clickable ? You need to create a ony submenu controller not need to create a parent menu controller Link to comment Share on other sites More sharing options...
pawelszulc Posted October 18, 2019 Share Posted October 18, 2019 (edited) @Nishith so, $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminSubMenu"; $tab->name = array(); foreach (Language::getLanguages(true) as $lang) { $tab->name[$lang['id_lang']] = 'Sub menu'; } $tab->id_parent = (int)Tab::getIdFromClassName('< What I should add here, since I don't have to create a parent controller'); $tab->module = $this->name; $tab->add(); Edited October 18, 2019 by pawelszulc (see edit history) Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted October 19, 2019 Share Posted October 19, 2019 @pawelszulc If you need create your own custom parent tab then you need create a paraen tab class. For example like this $languages = Language::getLanguages(false); //Main Parent menu if (!(int) Tab::getIdFromClassName('AdminInspiration')) { $parentTab = new Tab(); $parentTab->active = 1; $parentTab->name = array(); $parentTab->class_name = "AdminInspiration"; foreach ($languages as $language) { $parentTab->name[$language['id_lang']] = 'Inspiration'; } $parentTab->id_parent = 0; $parentTab->module = ''; $parentTab->add(); } //Sub menu code if (!(int) Tab::getIdFromClassName('AdminWallBackground')) { $parentTabID = Tab::getIdFromClassName('AdminInspiration'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminWallBackground"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Wall Background'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } if (!(int) Tab::getIdFromClassName('AdminFrames')) { $parentTabID = Tab::getIdFromClassName('AdminInspiration'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminFrames"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Frames'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } if you need create only submenu inside the prestashop native menu then you need to use pretsashop class.This example create submenu inside the Module tab. $languages = Language::getLanguages(false); //Main Parent menu //Sub menu code if (!(int) Tab::getIdFromClassName('AdminWallBackground')) { $parentTabID = Tab::getIdFromClassName('AdminParentModulesSf'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminWallBackground"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Wall Background'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } if (!(int) Tab::getIdFromClassName('AdminFrames')) { $parentTabID = Tab::getIdFromClassName('AdminParentModulesSf'); $parentTab = new Tab($parentTabID); $tab = new Tab(); $tab->active = 1; $tab->class_name = "AdminFrames"; $tab->name = array(); foreach ($languages as $language) { $tab->name[$language['id_lang']] = $this->l('Frames'); } $tab->id_parent = $parentTab->id; $tab->module = $this->name; $tab->add(); } See herehttps://devdocs.prestashop.com/1.7/modules/concepts/controllers/admin-controllers/tabs/ Link to comment Share on other sites More sharing options...
pawelszulc Posted October 23, 2019 Share Posted October 23, 2019 @Nishith Please tel me how to set params to required or not required i public function hookModuleRoutes() {} 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