Jump to content

How to add module configuration page to side menu link


harish.m

Recommended Posts

I am trying to add module configuration page to backoffice sidebar menu

we have added this installTab  function to add menu in sidebar but having error in creating 3rd menu configuration in sidebar   .

I got the token mismatch error .  

 

public function installTab()
    {
        $languages = Language::getLanguages(false);
        $tab = new Tab();
        $name = array();
        foreach ($languages as $lang) {
            $name[$lang['id_lang']] = $this->l('Competition');
        }
        $tab->name = $name;
        $tab->module = $this->name;
        if (version_compare(_PS_VERSION_, '1.7.0', '>=') === true) {
            $tab->id_parent = 2;
        }
        $tab->class_name = 'COMPETITION';
        $tab->save();
        Db::getInstance()->execute(
            '
            UPDATE `'._DB_PREFIX_.'tab` t
            SET position = 5
            WHERE id_tab = '.(int)$tab->id
        );
        $tab->cleanPositions(0);
        $tab1 = new Tab();
        $name = array();
        foreach ($languages as $lang) {
            $name[$lang['id_lang']] = $this->l('Products');
        }
        $tab1->name = $name;
        $tab1->module = $this->name;
        $tab1->class_name = 'AdminProductCompare';
        $tab1->id_parent = (int)$tab->id;
        $tab1->save();
        $tab2 = new Tab();
        $name = array();
        foreach ($languages as $lang) {
            $name[$lang['id_lang']] = $this->l('Settings');
        }
        $tab2->name = $name;
        $tab2->class_name = 'AdminModules&configure=moduleclassname';
        $tab2->id_parent = (int)$tab->id;
        $tab2->save();
    }

Invalid security key.png

Edited by harish.m
security (see edit history)
Link to comment
Share on other sites

  • 1 year later...

For anyone else looking for the solution try this:

create a admin controller than link tab to controller and than add redirect to configure page:

public function __construct()
    {
         parent::__construct();
    }

    public function initContent()
    { 
         $configure = $this->context->link->getAdminLink('AdminModules', false)
            .'&configure='.$this->module->name.'&tab_module='.$this->module->tab.'&module_name='.$this->module- >name.'&token='.Tools::getAdminTokenLite('AdminModules');
            Tools::redirectAdmin($configure);
            die();
    }

 

Edited by vividusdesigns (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 7 months later...
On 6/10/2019 at 9:14 PM, vividusdesigns said:

For anyone else looking for the solution try this:

create a admin controller than link tab to controller and than add redirect to configure page:


public function __construct()
    {
         parent::__construct();
    }

    public function initContent()
    { 
         $configure = $this->context->link->getAdminLink('AdminModules', false)
            .'&configure='.$this->module->name.'&tab_module='.$this->module->tab.'&module_name='.$this->module- >name.'&token='.Tools::getAdminTokenLite('AdminModules');
            Tools::redirectAdmin($configure);
            die();
    }

 

Hi Vividusdesigns, thank you to your kindness on the solution, do you mind to explain a little bit on the step?

1. How to Create Admin controller?

2. How to link tab to controller?

3. How to add redirect to configure page?

Thank you in advance.

Link to comment
Share on other sites

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