Search
Other Advanced Module Manager questions
Forum

PHP condition

Jordan Weinstein's Avatar Jordan Weinstein
Hello,

I have used some PHP code to retrieve the ?string value which I append to any url, for example:

For the URL mysite.com/any-page?auth=1
<?php
$parts = parse_url($url);
parse_str($parts['query'], $query);
echo 'Value is: ' . $query['auth'];
//the echo is just for debugging
?>

If I wanted to used AMM to show a module for auth=1, I tried this in the PHP condition:
$parts = parse_url($url);
parse_str($parts['query'], $query);
return ($query['auth'] == '1');

However, not sure I am interpreting the example in the example you give in the module. Could you help show a module for auth=1

Jordan
Peter van Westen's Avatar Peter van Westen ADMIN
You can use the Joomla input object:
return JFactory::getApplication()->input->get('auth') === '1';
Or shorter, by using the ready-to-use $app object:
return $app->input->get('auth') === '1';
Please post a rating at the Joomla! Extensions Directory
Jordan Weinstein's Avatar Jordan Weinstein
Wow...this is so incredibly useful.

Obviously not secure but an interesting way to hide content based on URL parameters.

Jordan
Peter van Westen's Avatar Peter van Westen ADMIN
PS: The input thing also works on POST data, not just GET (query) data.
So you could use this on form data you send to a page using POST.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription