Reading list Switch to dark mode

    How to create inline admin tab in PrestaShop 1.7

    Updated 16 July 2021

    Create an inline admin tab in PrestaShop 1.7

    PrestaShop 1.7 introduced new inline tab within the main admin tab. Using these inline tabs minimize so many outside tabs in PrestaShop 1.7 admin panel.

    To add these tab you have to add some line of code in you PrestaShop 1.6 create tab code.

    We can create tab in PrestaShop 1.6 like this,

    public function installTab($className, $tabName, $tabParentName = false)
    {
      $tab = new Tab();
      $tab->active = 1;
      $tab->class_name = $className;
      $tab->name = array();
    
      foreach (Language::getLanguages(true) as $lang) {
         $tab->name[$lang['id_lang']] = $tabName;
      }
      if ($tabParentName) {
         $tab->id_parent = (int) Tab::getIdFromClassName($tabParentName);
      } else {
         $tab->id_parent = 0;
      }
      $tab->module = $this->name;
      return $tab->add();
    }
    
    

    Now if you want to create a Tab hierarchy like this,

    Searching for an experienced
    Prestashop Company ?
    Read More

    Using the above function you can create your tab,

    $this->installTab('AdminParentTab', 'My Module');
    
    $this->installTab('AdminModuleTab', 'Module Tab', 'AdminParentTab');
    
    $this->installTab('AdminSubChildTab', 'Manage Tab', 'AdminModuleTab');
    
    $this->installTab('AdminTabOne', 'Tab One', 'AdminSubChildTab');
    
    $this->installTab('AdminTabTwo', 'Tab Two', 'AdminSubChildTab');
    
    $this->installTab('AdminTabThree', 'Tab Three', 'AdminSubChildTab');
    

    Line number 5 in the above code,

    $this->installTab('AdminSubChildTab', 'Manage Tab', 'AdminModuleTab');

    this line of tab will be display on hover of ‘Module Tab’, We just have to do now, make this tab as a parent for other subtab. It will automatically display as a inline tab.

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    1 comments

  • vivi1
    Hello,

    Should we make a controller for each tab?
    What do controllers look like?

    Because I have only the basic controller AdminMyModuleController
    and another controller for a tab that i would like to show.

    Is it possible to have a complete example with controllers?

  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home