如何在prestashop管理员模块中添加多个子菜单选项卡?

时间:2016-05-12 09:00:08

标签: prestashop submenu

我在PrestaShop中安装了一个模块,并在安装模块时添加了左侧菜单及其模块名称。我想在安装模块时为模块菜单选项卡添加多个子菜单。请帮帮我

1 个答案:

答案 0 :(得分:0)

private function CreateMymoduleAdminTabs() {
        $langs = Language::getLanguages();
        $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
        $smarttab = new Tab();
        $smarttab->class_name = "AdminModuleName";
        $smarttab->module = "";
        $smarttab->id_parent = 0;
        foreach ($langs as $l) {
            $smarttab->name[$l['id_lang']] = $this->l('Configuration');
        }
        $smarttab->save();
        $tab_id = $smarttab->id;
        $tabvalue = array(
            array(
                'class_name' => 'AdminMenu1',
                'id_parent' => 15,
                'module' => 'modulename',
                'name' => 'tabName1',
            ),
            array(
                'class_name' => 'AdminMenu2',
                'id_parent' => 15,
                'module' => 'modulename',
                'name' => 'tabName2',
            ),
            array(
                'class_name' => 'AdminMenu3',
                'id_parent' => 15,
                'module' => 'modulename',
                'name' => 'tabName3',
            ),
        );
        foreach ($tabvalue as $tab) {
            $newtab = new Tab();
            $newtab->class_name = $tab['class_name'];
            $newtab->id_parent = $tab_id;
            $newtab->module = $tab['module'];
            foreach ($langs as $l) {
                $newtab->name[$l['id_lang']] = $this->l($tab['name']);
            }
            $newtab->save();
        }
        return true;
    }

Call this function in install function of your module.
 $this->CreateMymoduleAdminTabs();
Change the module name and class names as per your module.