Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] var is not retrieved via JRequest::getVar in ...

var is not retrieved via JRequest::getVar in ... 24 Oct 2013 09:59 #11446

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
... a external module.

When I tried to run (besides a component from cook) some module (downloaded from JED) that contains post form it doesn't work.
I found that JRequest::getVar ('some_param') is emtpy after post form was sent.

I am stuck at this moment because I do not know what is happening.
When I run a module besides for example article component everthing is fine.

J3 component

please any idea?
The administrator has disabled public write access.

var is not retrieved via JRequest::getVar in ... 24 Oct 2013 10:24 #11448

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
It is normal.

Post is always killed after been used and URL is rewritted for a proper redirection.

What do you want to do ?
POST must be catched only by the controller.
If you use with a module, the post is sent from the module, but to the component controller, and it should work.

If you want to keep some values of the post after the redirection, you should better use session vars :
application userStates vars

Another solution is to include the var you want in the redirected url.

applyRedirection() accept some extra vars to chain to the redirection. Place your result var here (At this point, POST is still available)
After redirection post is lost.

Hope it helps.

Also, JRequest is deprecated. Use JInput instead.
Coding is now a piece of cake
The administrator has disabled public write access.

var is not retrieved via JRequest::getVar in ... 24 Oct 2013 10:53 #11450

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
Thank you. I can use this tips for my own module and I will do it.
The bad is the external module is not mine and hacking is the last thing I want to do
The administrator has disabled public write access.

var is not retrieved via JRequest::getVar in ... 24 Oct 2013 11:41 #11452

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
I put var1 and var2 in admin/helper.php. It works
$authorizedInUrl = array(
					'option' => null, 
					'view' => null, 
					'layout' => null, 
					'Itemid' => null, 
					'tmpl' => null,
					'object' => null,
					'lang' => null,
                                       'var1' => null,
                                        'var2' => null );

Now the name of the vars + values are visible in URL. How can I hide them?
The administrator has disabled public write access.

var is not retrieved via JRequest::getVar in ... 24 Oct 2013 12:48 #11453

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
You will always see the values because it is a GET

you can hide the var name with router.php (handling SEF for Thoses 2 vars)

The other workaround is to use states vars, but it would work differently and you said you do not want to hack the module.
Coding is now a piece of cake
The administrator has disabled public write access.

var is not retrieved via JRequest::getVar in ... 24 Oct 2013 15:43 #11454

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
ok thanks I partialy made it.
But anyway we can not use any module besides running cook component that post some data.
On the other side the module can work besides article component with no problem. So what is the difference??
The administrator has disabled public write access.

var is not retrieved via JRequest::getVar in ... 24 Oct 2013 16:53 #11455

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
One more thing that makes me happier.
After module sent post data I used the redirect to origin page so the params are not visible in URL anymore.
$urlredirect = JURI::current() . "\n";
$sent = whatever;
JFactory::getApplication()->redirect($urlredirect);
The administrator has disabled public write access.

var is not retrieved via JRequest::getVar in ... 30 Oct 2013 09:27 #11484

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Because the modules you are using are not written properly.

The REST standard defines this :
GET : Used to display/browse datas.
POST : Used to process a CRUD task.

Modules are not processing tasks. Only component does.
Your module shouldn't use POSTat all.

Then, about the GET, it is often the case when for example your component does not redirect Itemid, then your menus does not work... Famous one in Virtuemart 1,0...

You did absolutly correctly, adding a follower such you does.
Applying a redirection as you did afterwards will maybe loose the POST and GET. Only with your component feature it can work :
applyRedirection()... Proposed by Cook.

Hope I wen around the case...
Coding is now a piece of cake
The administrator has disabled public write access.

var is not retrieved via JRequest::getVar in ... 30 Oct 2013 09:43 #11485

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
Thank you.
Now I see. You are right, the module should not POST data. I need to build simple component for processing this.
The administrator has disabled public write access.
Time to create page: 0.067 seconds

Get Started