Jump to content

Why my custom module generate different link in tab menu?


Recommended Posts

AdminParentMyCustomModuleHi!

I in my module create two links in tab menu:

private function installTab(Module $module): bool 
    {
        $tabId = (int) Tab::getIdFromClassName('AdminParentMyCustomModule');
        if (!$tabId) {
            $tab = new Tab();
            $tab->active = 1;
            $tab->class_name = 'AdminParentMyCustomModule';
            $tab->name = array();
            foreach (Language::getLanguages(true) as $lang) {
                $tab->name[$lang['id_lang']] = 'AdminParentMyCustomModule';
            }
            $tab->id_parent = Tab::getIdFromClassName('AdminCatalog');
            $tab->module = $module->name;

            if (!$tab->add())
            {
                return false;
            }
        }
        
        $tabId = (int) Tab::getIdFromClassName('AdminMyCustomModule');
        if (!$tabId) {
            $tab = new Tab();
            $tab->active = 1;
            $tab->class_name = 'AdminMyCustomModule';
            $tab->name = array();
            foreach (Language::getLanguages(true) as $lang) {
                $tab->name[$lang['id_lang']] = 'AdminMyCustomModule';
            }
            $tab->id_parent = (int) Tab::getIdFromClassName('AdminParentMyCustomModule');
            $tab->module = $module->name;

            if(!$tab->add())
            {
                return false;
            }
        }

        $tabId = (int) Tab::getIdFromClassName('AdminMyCustomModuleProduct');
        if (!$tabId) {
            $tab = new Tab();
            $tab->active = 1;
            $tab->class_name = 'AdminMyCustomModuleProduct';
            $tab->name = array();
            foreach (Language::getLanguages(true) as $lang) {
                $tab->name[$lang['id_lang']] = 'AdminMyCustomModuleProduct';
            }
            $tab->id_parent = (int) Tab::getIdFromClassName('AdminParentMyCustomModule');
            $tab->module = $module->name;

            if(!$tab->add())
            {
                return false;
            }
        }
        return true;
    }

After install my module in tab menu generating two links:

http://localhost/admin777/index.php/modules/mycustommodule/?_token=uDrV1ezY17wRAj4H2pjfNPjU-G2gaa3VwpZVhr6l1oM

and

http://localhost/admin777/index.php?controller=AdminMyCustomModuleProduct&token=607d95d3a53b0c96d4a6c4c82f8dc2c0

Why do links look different? And the second link is not working.

How can I fix the second link?

Thank You.

Link to comment
Share on other sites

  • 5 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...