Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way of adding a quick link on the administration page to a module's configuration?

Tags:

prestashop

Is it possible to add a link on the top menubar of the Administration page (Catalog, Orders, Customers...) going straight to a module's configuration page? I've inherited a large module with a ton of messy code that I'd really like to leave be, if at all possible.

The only requirement is that its configuration has to be accessible from that menu bar in particular (or, if there's no other possible option, from the quick links section; this one in particular can easily be achieved, except for the token part).

EDIT: I managed to pull it off by creating an Admin controller, but I am having issues generating the correct access token. I do not really know what to do to fix it and, as such, I am hereby launching (yet another) bounty.

Here's the code I am using for the redirect:

<?php

class AdminMultiBlockController extends AdminController 
{   
    public function __construct()
    {
        global $cookie;

        // this doesn't really work
        $tab = 'adminmodules';
        $token = Tools::getAdminToken($tab.(int)(Tab::getIdFromClassName($tab)).(int)($cookie->id_employee));

        Tools::redirectAdmin('index.php?controller=adminmodules&configure=egr_MultiBlockSlider&token=' . $token);
    }
}

My workaround was to force a working token, but this won't do.

What am I doing wrong? What parameters should I put inside the getAdminToken() function in order to successfully access a module's configuration?

I am currently using Prestashop v1.5.1.

Cheers guys!

like image 780
João Pereira Avatar asked Nov 16 '25 14:11

João Pereira


1 Answers

Not being able to reproduce the problem, I can only guess.
However, try with the following code:

$url  = 'index.php?controller=AdminModules&configure=egr_MultiBlockSlider';
$url .= '&token='.Tools::getAdminTokenLite('AdminModules');
Tools::redirectAdmin($url);

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!