31

$app = JFactory::getApplication(); $postData = $app->input->post; Is the way to go, you will get a JInput object and can use it like JRequest $var = $postData->get('varname', 'defaultvalue', 'filter'); The filter could be 'int', 'cmd' or many others - the complete list can be found in this function: https://github.com/joomla/joomla-cms/blob/...


24

For Joomla 3.x While the code from the other answer will work, JRequest is deprecated, therefore you should use the following: $jinput = JFactory::getApplication()->input; echo $jinput->get('option'); For example, if you are displaying an Article and use the above code, it will output com_content


9

For Joomla 2.5 We can check by getting the URL parameters, using the JRequest::getVar() method and check for the option parameter. jimport( 'joomla.environment.request' ); echo JRequest::getVar('option', '') JRequest API Documentation


8

OK, so let us look at what options are available. The examples below are using JInput and have been tested in Joomla 3.3. I am POSTing the following data at Joomla: stuff[abc]=1 stuff[def]=75 stuff[123]=<script src="http://imanaughtysite.com/muahahaha.js"/> I want to get a clean array of integers, so the expected result is: $expectedResult = array(...


7

Joomla does not support multiple type as filters. This can not be done either using JRequest or JInput. There is no workaround available in Joomla till now. You need to handle multiple filters in your code only.


7

Please check this code - $jinput = JFactory::getApplication()->input; $ip = $jinput->server->get('REMOTE_ADDR', '', ''); //Here default value and filter are null, so you can write $ip = $jinput->server->get('REMOTE_ADDR'); By this you can get the ip address.


4

You're definitely not missing something. If you find that you're doing this regularly, you can create a system plugin to extend the existing JRequest class and add a new filter type to that.


3

It seems another way to accomplish this is simply pass an empty array: $app = JFactory::getApplication(); $postData = $app->input->getArray(array()); This will retrieve everything in the JInput data var as if you were accessing the $_REQUEST super. This does not work in the Joomla! 2.5.x version of JInput though.


2

I put a one-liner - and it works similar to your answer, because I do not use the object $jinput more than once; again thank you Joomler +1: $ip = JFactory::getApplication()->input->server->get('REMOTE_ADDR',''); You could remove the second parameter too. If so, the $ip will be set to null if REMOTE_ADDR is not available.


2

Because the function argument contains a & at the beginning, it requires a variable to be passed by reference rather than referencing an object value directly. So you'll need to replace this: if ($this->isArticleExcluded(JRequest::getInt('id', 0))) { } with this: $id = JFactory::getApplication()->input->get('id'); if ($this->...


1

You are doing a small mistake here. Have a look below: What you tried: $post = JFactory::getApplication()->input->get('post', '','raw'); Here, 'post' must be the name parameter of the input field of which you want to fetch the value. Example below: $post = JFactory::getApplication()->input->post->get('name', '','raw'); Output: will give ...


1

Why not use this? basename(JPATH_COMPONENT);


1

Another approach is through the JRouter object: JFactory::getApplication()->getRouter()->getVars()["option"] Unsure if there is ever a practical difference between the JRouter value and the value returned through JInput.


Only top voted, non community-wiki answers of a minimum length are eligible