Create an inline admin tab in PrestaShop 1.7

 

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,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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,

create inline admin tab PrestaShop 1.7

 

Using the above function you can create your tab,

1
2
3
4
5
6
7
8
9
10
11
$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,

1
$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.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...