diff --git a/modules/mod_finder/helper.php b/modules/mod_finder/helper.php
index dad6287c4653d..6bf5a25c73e6e 100644
--- a/modules/mod_finder/helper.php
+++ b/modules/mod_finder/helper.php
@@ -31,31 +31,27 @@ class ModFinderHelper
*/
public static function getGetFields($route = null, $paramItem = 0)
{
- $fields = null;
- $uri = JUri::getInstance(JRoute::_($route));
+ // Determine if there is an item id before routing.
+ $needId = !JURI::getInstance($route)->getVar('Itemid');
+
+ $fields = array();
+ $uri = JURI::getInstance(JRoute::_($route));
$uri->delVar('q');
- $elements = $uri->getQuery(true);
// Create hidden input elements for each part of the URI.
- // Add the current menu id if it doesn't have one
- foreach ($elements as $n => $v)
+ foreach ($uri->getQuery(true) as $n => $v)
{
- if ($n == 'Itemid')
- {
- continue;
- }
-
- $fields .= '';
+ $fields[] = '';
}
- /*
- * Figure out the Itemid value
- * First, check if the param is set. If not, fall back to the Itemid from the JInput object
- */
- $Itemid = $paramItem > 0 ? $paramItem : JFactory::getApplication()->input->getInt('Itemid');
- $fields .= '';
+ // Add a field for Itemid if we need one.
+ if ($needId)
+ {
+ $id = JFactory::getApplication()->input->get('Itemid', '0', 'int');
+ $fields[] = '';
+ }
- return $fields;
+ return implode('', $fields);
}
/**