I have an own Plugin for Jobs with a list and a show View (on the same page). I entered my params in the "postVarSets" in the realurl_conf.php (grouped by "job-view") and so my Links look like following:
/jobs - List View
/jobs/job-view/show/Job/testjob - Detail View
Now i can shorten my path with the "encodeSpURL_postProc":
$params['URL'] = str_replace('job-view/show/Job', 'job-detail', $params['URL']);
and decode by
$params['URL'] = str_replace('job-detail', 'job-view/show/Job', $params['URL']);
/jobs - List View
/jobs/job-detail/testjob - Detail View
But i want my Detail View to look like:
/jobs/testjob
But I can't use
$params['URL'] = str_replace('jobs/job-view/show/Job', 'jobs', $params['URL']);
because the decode
$params['URL'] = str_replace('jobs', 'jobs/job-view/show/Job', $params['URL']);
would also try to decode the List View back.
So, is it possible to shorten the URL path of the detail page to the second level?
This is very easy to achieve using a combination of fixedPostVars
and TS conditions.
Assuming that your extensions's parameters are something like tx_jobs_list
, you will have the following in the realurl config:
'fixedPostVars' => [
$jobDetailPagePid => [
[
'GETvar' => 'tx_jobs_list[uid]',
'lookUpTable' => [
...
]
],
[
'GETvar' => 'tx_jobs_list[controller]',
'noMatch' => 'bypass'
],
[
'GETvar' => 'tx_jobs_list[action]',
'noMatch' => 'bypass'
],
],
],
$jobDetailPagePid
must be a page id. You cannot use _DEFAULT
here.
You also need TS conditions for the detail page:
[globalString = GP:tx_jobs_list|uid = /\d+\]
config.defaultGetVars {
tx_jobs_list {
controller = List
action = single
}
}
[global]
That's all.