Jump to content

How create link in side menu Back Office


Recommended Posts

Hello,

I am a beginner in Prestashop 1.7.8 and I try to create a link in the side menu of the back office in order to arrive on a new page. I followed the documentation but it doesn't work.

My module is recognized and installed.

Any idea why my code isn't working?

class Gaston extends Module
{    
    public function __construct()
    {
        $this->tabs = [   
                'name' => 'Gaston',
                'visible' => true      
        ];
            
        $this->name = 'Gaston';
//...
}

 

Edited by NewDevOnPrest (see edit history)
Link to comment
Share on other sites

  • NewDevOnPrest changed the title to How create link in side menu Back Office

Thanks for your help knacky,
I followed the doc. I just forgot to target the controller.

My module

class Gaston extends Module
{    
    public function __construct()
    {
        $this->tabs = [   
                'name' => 'Gaston',
                'class_name' => 'Gaston',
                'visible' => true      
        ];
            
        $this->name = 'Gaston';
//...
}

My Controller

class GastonController extends FrameworkBundleAdminController
{
//...
}

 

Edited by NewDevOnPrest (see edit history)
Link to comment
Share on other sites

<?php
use Language;

class Example_module_mailtheme extends Module
{
    public function install()
    {
        return parent::install()
            && $this->installTab()
        ;
    }

    public function uninstall()
    {
        return parent::uninstall()
            && $this->uninstallTab()
        ;
    }

    public function enable($force_all = false)
    {
        return parent::enable($force_all)
            && $this->installTab()
        ;
    }

    public function disable($force_all = false)
    {
        return parent::disable($force_all)
            && $this->uninstallTab()
        ;
    }

    private function installTab()
    {
        $tabId = (int) Tab::getIdFromClassName('MyModuleDemoController');
        if (!$tabId) {
            $tabId = null;
        }

        $tab = new Tab($tabId);
        $tab->active = 1;
        $tab->class_name = 'MyModuleDemoController';
        // Only since 1.7.7, you can define a route name
        $tab->route_name = 'admin_my_symfony_routing';
        $tab->name = array();
        foreach (Language::getLanguages() as $lang) {
            $tab->name[$lang['id_lang']] = $this->trans('My Module Demo', array(), 'Modules.MyModule.Admin', $lang['locale']);
        }
        $tab->id_parent = (int) Tab::getIdFromClassName('ShopParameters');
        $tab->module = $this->name;

        return $tab->save();
    }

    private function uninstallTab()
    {
        $tabId = (int) Tab::getIdFromClassName('MyModuleDemoController');
        if (!$tabId) {
            return true;
        }

        $tab = new Tab($tabId);

        return $tab->delete();
    }
}

 

Link to comment
Share on other sites

  • 2 weeks 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...