0
votes

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?

3
did you tried to use switchableControllerActions ?Andrei Todorut
I don't know how switchableControllerActions have something to do with this?Philipp Parzer

3 Answers

1
votes

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.

0
votes

Take a closer look at the documentation: https://github.com/dmitryd/typo3-realurl/wiki/Configuration-reference#fixedpostvars Maybe this can help you.

I never had to change the decode/encode functions to get what I need.

0
votes

You can use encodeSpURL_postProc and decodeSpURL_preProc in your real_conf.php file like below.

'encodeSpURL_postProc' => array('user_encodeSpURL_postProc'),
'decodeSpURL_preProc' => array('user_decodeSpURL_preProc'),

function user_encodeSpURL_postProc(&$params, &$ref) {
   $params['URL'] = str_replace('jobs', 'job-view/show/Job/', $params['URL']);
}
function user_decodeSpURL_preProc(&$params, &$ref) {
   $params['URL'] = str_replace('job-view/show/Job/', 'jobs', $params['URL']);
}