Task at our agency: In a menu of a TYPO3 installation (TYPO3 v9.5), the subtitles of the menu items should be linked to their corresponding pages, meaning that the link target of the subtitles should match the link target of the actual menu items. It would seem logical to set a typolink with parameter.data = field:uid. However, this only works for regular pages that do not point to other pages. For shortcut menu items, this would mean that the menu item itself would link to the correct destination/reference page after the menu has been built normally, while the subtitle would link to the page itself and therefore result in a 404 error.
So we intervene after the subtitle has been generated and override the actual link target (the uid) with the correct link target (shortcut), meaning: we access the relevant menu object (here, for example, mainpain) and create an override (subtitle defined with after):
lib.menu.mainpain.2.NO {
after.typolink {
parameter.data.override = field:shortcut
parameter.data.override.if {
isTrue.field = shortcut
}
}
}
The if statement then checks whether a shortcut page entry actually exists, so that for other menu items, the uid can be used as a fallback for the link target. Seen at our internet agency on a website using the TYPO3 9 CMS.
