Jump to content

How to create a custom navigation bar in the module backoffice


beginner1
 Share

Recommended Posts

Hello!

 

Are you talking about toolbar like this  ?

00000583.png

 

You can do this in "Tab" class that extends ModuleAdminController

Please take a look at function 

public function initPageHeaderToolbar()

You can add your own menu item like this

            $this->page_header_toolbar_btn['new_carrier'] = array(
                'href' => $this->context->link->getAdminLink('AdminCarriers').'&onboarding_carrier',
                'desc' => $this->l('Add new carrier', null, null, false),
                'icon' => 'process-icon-new'
            );

So function could look like this (this is example from AdminCarriersControllerCore):

    public function initPageHeaderToolbar()
    {
        $this->page_header_toolbar_title = $this->l('Carriers');
        if ($this->display != 'view') {
            $this->page_header_toolbar_btn['new_carrier'] = array(
                'href' => $this->context->link->getAdminLink('AdminCarriers').'&onboarding_carrier',
                'desc' => $this->l('Add new carrier', null, null, false),
                'icon' => 'process-icon-new'
            );
        }

        parent::initPageHeaderToolbar();
    }

 

Share this post


Link to post
Share on other sites

6 hours ago, Involic said:

Hello!

 

Are you talking about toolbar like this  ?

00000583.png

 

You can do this in "Tab" class that extends ModuleAdminController

Please take a look at function 

public function initPageHeaderToolbar()

You can add your own menu item like this

            $this->page_header_toolbar_btn['new_carrier'] = array(
                'href' => $this->context->link->getAdminLink('AdminCarriers').'&onboarding_carrier',
                'desc' => $this->l('Add new carrier', null, null, false),
                'icon' => 'process-icon-new'
            );

So function could look like this (this is example from AdminCarriersControllerCore):

    public function initPageHeaderToolbar()
    {
        $this->page_header_toolbar_title = $this->l('Carriers');
        if ($this->display != 'view') {
            $this->page_header_toolbar_btn['new_carrier'] = array(
                'href' => $this->context->link->getAdminLink('AdminCarriers').'&onboarding_carrier',
                'desc' => $this->l('Add new carrier', null, null, false),
                'icon' => 'process-icon-new'
            );
        }

        parent::initPageHeaderToolbar();
    }

 

Hi, how can I do this from a module? I want to implement it in my module's backoffice.

Edited by beginner1 (see edit history)

Share this post


Link to post
Share on other sites

1 hour ago, beginner1 said:

Hi, how can I do this from a module? I want to implement it in my module's backoffice.

1

 

The part of code that I give you previusly is could be used also in the module.

So simple module contains only one file "modulename.php". Additionally you will be need to register controller/tab

I can't find any point to documentation. But very similar question/answer in SO - https://stackoverflow.com/questions/15027548/prestashop-custom-tab-in-back-office

So you will have 

YourAdminControllerName

Inside it you will be possible apply this code (adding menu). 

As an example, you can take a look into few existing modules. For example themeconfigurator . You can find controller under /modules/themeconfigurator/controllers/

Share this post


Link to post
Share on other sites

4 hours ago, Involic said:

 

The part of code that I give you previusly is could be used also in the module.

So simple module contains only one file "modulename.php". Additionally you will be need to register controller/tab

I can't find any point to documentation. But very similar question/answer in SO - https://stackoverflow.com/questions/15027548/prestashop-custom-tab-in-back-office

So you will have 

YourAdminControllerName

Inside it you will be possible apply this code (adding menu). 

As an example, you can take a look into few existing modules. For example themeconfigurator . You can find controller under /modules/themeconfigurator/controllers/

Can you tell me how do I know that a controller is working or not? The module.php file is the one that actually loads up so how do I know that the controller is working?  I made a controller but I don't know whether it is working or not. The only statement about the controller in the some other file is:

$this->controllers = array('myController');

I have written this in my module.php file. Apart from this I haven't given a reference anywhere about myController. Is this the only thing required for running the controller in the module?

Edited by beginner1 (see edit history)

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More