#14634Typolink to a page with certain type doesn't work if type is zero
Description
Look at the the following typoscript code:
20 = TEXT
20.value = Template wechseln
20.typolink.parameter.data = field:uid
20.typolink.parameter.wrap = |,0
So I want to make a link to the current page with typenumber 0 set ( I needed this to make a link for the user to change the type of the page to 1 and vice versa).
If you enter a number else than 0, all works fine. But 0 doesn’t work.
So here is how I solved it:
After some reverse engineering I came across the method “linkData” in class “t3lib_TSTemplate”. The typenum given above is passed as the last parameter. In the comment it means:
“If you set this value to something else than a blank string, then the typeNumber used in the link will be forced to this value. Normally the typeNum is based on the target set OR on $GLOBALS[‘TSFE’]->config[‘config’][‘forceTypeValue’] if found.”
OK, so far so good. But some lines later, the code (line 1311) is the following:
//line 1310
if (!$typeOverride && intval($GLOBALS[‘TSFE’]->config[‘config’][‘forceTypeValue’])) {
//line 1312
So actually it is not tested on an empty string but on an “empty” value! As PHP interprets 0 as empty (it doesn’t get passed as string but as number) the test actually passes and the typenum from forceTypeValue” is inserted.
So I changed the line and now it works:
if ($typeOverride == ‘’ && intval($GLOBALS[‘TSFE’]->config[‘config’][‘forceTypeValue’])) {
Now it’s done exactly what is mentioned in the comment.
(issue imported from #M931)
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.