JInput Help Topic is solved

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
springburn
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Feb 28, 2017 5:23 pm

JInput Help

Post by springburn » Mon Jul 01, 2019 4:24 pm

Greetings -

Core Challenge: Cannot capture GET variables. Given variable always expresses as empty. Example of the calling URI (testing included '&' and '?' delimiters):

Code: Select all

 ...adminpage&did=206
Code samples - I've tried numerous flavors of these lines, but here is where I'm at today:

Code: Select all

$jinput = JFactory::getApplication()->input;
$did = $jinput->get->get('did', '0', 'INT');
All to no avail - $did is always the default setting, zero in this example.

I have read all manuals thoroughly; I've done extensive testing. I have years of experience with $_POST & $_GET. We run Joomla version 3.9.8.

What am I missing? Any direction at all would be so very appreciated. If it includes revealing myself as an idiot, I will accept that fate. Thank you!
Last edited by toivo on Mon Jul 01, 2019 4:41 pm, edited 1 time in total.
Reason: mod note: moved to 3.x Coding

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22278
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: JInput Help

Post by pe7er » Tue Jul 02, 2019 12:58 pm

springburn wrote:
Mon Jul 01, 2019 4:24 pm
What am I missing? Any direction at all would be so very appreciated. If it includes revealing myself as an idiot, I will accept that fate. Thank you!
No, you're not an idiot. You just have one "get" to many.

In cases like this, it's recommended to fix yourself a cup of coffee or tea. When you return at your computer, you'll probably see the error yourself and do a face palm (that's what I would do) ;)

Code: Select all

$jinput = JFactory::getApplication()->input;
$did = $jinput->get('did', '0', 'integer');
or use namespacing (since Joomla 3.8.0)

Code: Select all

use Joomla\CMS\Factory;

$jinput = Factory::getApplication()->input;
$did = $jinput->get('did', '0', 'integer');
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content

springburn
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Feb 28, 2017 5:23 pm

Re: JInput Help

Post by springburn » Mon Jul 08, 2019 2:09 pm

Thanks Pe7er -

So, I got that double-get from the Joomla board, here: https://docs.joomla.org/Retrieving_requ ... ing_JInput; scroll down to the section "Getting Values from a Super Global". You can see the implications for GET and POST.

Regardless, I tried numerous calls, with no successful results:

Code: Select all

use Joomla\CMS\Factory 
== "Class Factory not found"

Code: Select all

$jinput = Joomla/CMS/JFactory::getApplication()->input; 
$did = $jinput->get->get('itpid', '0',integer);
== "Call to a member function get() on null"

Code: Select all

$jinput = Joomla/CMS/JFactory::getApplication()->input; 
$did = $jinput->get('itpid', '0',integer);
== "Call to a member function get() on float"

All things considered, I feel more than ever there is something more fundemental going on - I still get no result to a simple test for $_GET['itpid'] - does that tell me anything? At least where to look?

Thanks again for all your help - I know there is a solution here somewhere!

Best ~
Springburn

springburn
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Feb 28, 2017 5:23 pm

Re: JInput Help

Post by springburn » Wed Jul 10, 2019 3:47 pm

All -

I have found a solution - it appears that '&' had to be '?', whereas I assumed they were interchangeable.
I am now presuming that '?' has to be used for the first parameter passed.

Thanks to all for all the help along the way!

Best ~
Springburn


Post Reply

Return to “Joomla! 3.x Coding”