Forums

passing Parameters to form in full SEF-formatted-Url

mfeindt 10 Mar, 2016
hi there...

During setup of an application form, I came across a problem. I want to fill some form fields with data from a job offer. But the applicants should be able to apply through a simple link like domain.com/application-form-name/job-alias

But how can i now access the job-alias from within the form for example in a db-read-action? I can get the alias to the $form->data("job-alias") by passing the variable as get-parameter (domain.com/application-form-name?job-alias=...) but the specification requires the link in full sef-format (domain.com/application-form-name/job-alias)

i only found this thread in the forum where Max wrote to setup a custom router.php. But with this solution I do not know how to setup this.

Can anyone help me whit that?

Regards
Matthias
GreyHead 10 Mar, 2016
Answer
1 Likes
Hi Matthias,

Provided that you can rely on the format (big question) you can use Custom Code to Parse the data. Something like this:
<?php
$url = \JURI::getInstance()->toString();
// remove the prefix and the extra  /s
$url = str_replace(array('http://', 'https://'), '', $url);
$url = explode('/', $url);
$form->data['job-alias'] = $url[2]; // check the index here
?>

Bob
mfeindt 11 Mar, 2016
Hi Bob,

thanks for the fast reply.

That works and i'll use it for the moment, but is there also a solution for a custom router.php which parses all non-CF-get-parameters to $form->data?

Regards,
Matthias
GreyHead 11 Mar, 2016
1 Likes
HI Matthias,

Not that I know of - they are Non-CF menu items and a CF router would create and parse CF URLs only (I have no idea why Max has never written one for CF).

The general method [componentname]ParseRoute($segments) should allow you to parse SEF URLs from other components. I see that Joomla! 3.3 added a new JComponentRouterInterface - but I have no idea how to use it from reading the docs here.

Bob
mfeindt 14 Mar, 2016
Hi Bob,

thanks for the answer and the hint about JComponentRouterInterface. I should have a deeper look at this ;-)

regards
This topic is locked and no more replies can be posted.