Jump to content

The use of $_GET is forbidden; use Tools::getValue() instead


Kerm

Recommended Posts

Hello!

I use  $_GET in my module code for get some part of link:

link have &idreviewsOrderby=10 for example...

$orderBy = Tools::getIsset($_GET['idreviewsOrderby']) ? $_GET['idreviewsOrderby'] : 'id_customer_message';

But its not valid code for upload my module on addons...

 

With Tools::getValue() i cant get this data, what i must do for fix that?

Link to comment
Share on other sites

Strange that tools::getValue doesn't work !

Have you try with $_REQUEST instead of $_GET

 

You can test that??

 

I got url like that:

 

 

http://site.com/admin-dev/index.php?controller=AdminModules&configure=mymodule&tab_module=front_office_features&module_name=mymodule&idreviewsOrderby=33&idreviewsOrderway=asc&token=9692b64cf1fff2b3fa99a9bc0558f294

and normaly i can get with $_GET value of idreviewsOrderby but with Tools::getValue() it dosnt work...

Link to comment
Share on other sites

To define a default value you use this syntax

Tools::getValue('idreviewsOrderby','id_customer_message');

The second parameter of the function is the default value.

 

https://github.com/PrestaShop/PrestaShop/blob/1.6.1.x/classes/Tools.php#l453

 

Hello!,

First thanks for your reply.

 

Atm i fix this error this way:

$idreviewsOrderby = Tools::getValue('idreviewsOrderby');

$orderBy = (!empty($idreviewsOrderby)) ? $idreviewsOrderby : '31';

Its good to know about Tools::getValue('idreviewsOrderby','id_customer_message');, at this time i upload already my module for validate, may be i include this fix in next versions.

Link to comment
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
×
×
  • Create New...