Jump to content

Generate Admin Pages Token for Internal Linking and URL Query


poplol

Recommended Posts

Hi

I am currently doing a prestashop modification where i can pass parameters for example to show me order with the status from 8- 12.. Its code is ok.

The problem is that i copy and paste the token from other pages it works for the current user, but when the user changes it does not work. Can anyone help on how to create a new token for me to link internally my pages

LINK EXAMPLE = /admin/index.php?tab=AdminOrders&id_state=8&token=520975cae29bde4b1032996d68fbbb3d

I want the token= part to be dynamic.. can anyone help please

Thanks Presta Forum

Link to comment
Share on other sites

  • 9 months later...

Bumping this as it is coming up in search results near the top.

The admin token is generated on the fly so of course you cannot just copy and paste the rendered value and expect it to work.

It will depend a bit on the context of where you are generating the link as to what all is available but the usual approach looks like this:

taken from one of a custom module's hook functions:

$token=Tools::getAdminToken('[classname]'.intval(Tab::getIdFromClassName('[classname]')).intval($params['cookie']->id_employee));



Where you would replace "[classname]" with the name of the tab class you are linking to.

i.e. taken from the stock PayPal module:

$token=Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee));



Where you get the employee id from depends on what you are doing (a hook would see it in the $params array);

Cheers

  • Like 1
Link to comment
Share on other sites

  • 8 years 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...