2

we have a custom PHP script which is running under JUMI to perform and display some data.

The custom script is accessible to a SEF url such as

http://www.mysite.com/jumi-script

which is a rewritten version of

http://www.mysite.com/index.php?option=com_jumi&view=application&fileid=11&Itemid=271

Now we would like to filter data applying parameters such as

category=mycat&place=myplace

like this

/index.php?option=com_jumi&view=application&fileid=11&Itemid=271&category=mycat&place=myplace

and we would like to obtain a SEF url like this

/jumi-script/mycat/myplace

and process these variables in my script with

$mycat = JFactory::getApplication()->input->post->get('category');

$myplace = JFactory::getApplication()->input->post->get('place');

How do we obtain this? we are testing the

$currentUrl =& JURI::getInstance();
$currentUrl->setVar( 'mycat', $catvalue );

but we are loosing the rest of the query string. Can the above be achieved? Any suggestion?

Thank you

1

Looking at the router implementation of com_jumi here https://github.com/BonavalMultimedia/com_jumi/blob/master/com_jumi_bnvl/router.php for me it seems it doesn't handle extra parameters when sef is on (see JumiParseRoute function).

You need to modify this function to check for your extra parameters and add them to the $vars array, so they will be available using JInput or JRequest if you are on Joomla versions before 3.0

To check the parameters, simply look if they are defined in the $segments parameter.

To see if you have a category , a place or both you need to determine your own criteria or store the possible values anywhere you can check for sure which value 'type' is in every segment.

Example: my criteria is that URLs will always be jumi/category/place . Then:

$vars['category'] = $segments[1];
$vars['place'] = $segments[2];

Of course, you must check that $segment indexes are defined and do whatever checking you need.

Maybe you will want to produce SEF urls when creating the routes. Then you should modify the JumiBuildRoute function to follow your criteria.

Alternative to edit code

If you don't want to edit the routing code of the component then use an URL like this:

http://www.mysite.com/jumi-script?category=mycat&place=myplace

to get your script. Now, both values should be accessible through JInput or JRequest on older Joomla versions.

Regards,

0

For your url /index.php?option=com_jumi&view=application&fileid=11&Itemid=271&category=mycat&place=myplace :

$JInput    = JFactory::getApplication()->input;
$myRequest = $JInput->getArray(array(
    'option'  =>'',
    'view'    =>'',
    'fileid'  =>'', 
    'Itemid'  =>'',
    'category'=>'',
    'place'   =>''
));

Or if you want to filter the input:

$myRequest = $JInput->getArray(array(
    'option'  =>'word',
    'view'    =>'alnum',
    'fileid'  =>'int', 
    'Itemid'  =>'int',
    'category'=>'string',
    'place'   =>'string'
));

each input will return value as filtered type, or NULL if there is no value.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.