Thursday, June 30, 2022

[FIXED] How do I add a new parameter to the current index in PrestaShop?

Issue

How do I add a new parameter to the current index for the admin page (admin custom module) in PrestaShop?

I tried the following, but it's not working:

$this->setcurrentindex=$this->setcurrentindex.'&view=querydrlog';

What I need is:

http://localhost/raffleV1.3/oknr9hexztcseff5/index.php?controller=query&view=querydrlog&token=d81fcd49d179ae13444df0e8b2cccec6

When I click the asc or the pagination part the USL is:

http://localhost/raffleV1.3/oknr9hexztcseff5/index.php?controller=query&kits_query_drOrderby=id_query_dr&kits_query_drOrderway=desc&token=d81fcd49d179ae13444df0e8b2cccec6

To the above URL, I want to add '&view=querydrlog';, so that my pagination and asc will work correctly.


Solution

You can do it in your module admin controller by overriding the init() function of AdminController.

class YourAdminModuleController extends ModuleAdminController {
    protected $extra_params = '&view=querydrlog';

    public function init() {
        parent::init();
        self::$currentIndex .= $this->extra_params;
        $this->context->smarty->assign('current', self::$currentIndex);
    }
}

This will add your parameter to sorting link hrefs or pagination form action link.



Answered By - TheDrot
Answer Checked By - Candace Johnson (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.