Bug #97777
openlinkhandler config.recordLinks for news plugin (as example) not working if news article is translated
0%
Description
I use the LinkHandler API to provide the editor with the ability to link directly to news articles. In the default language everything works fine. However, if the news article is translated, no link is rendered by the f:link.typolink-ViewHelper.
- The news detail page including the plugin is fully translated.
- In the link selection in the backend I tested it with the default language UID as well as with the translated UID of the news article record without success.
config.recordLinks {
news {
typolink {
parameter = 292
additionalParams.data = field:uid
additionalParams.wrap = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]=|
useCacheHash = 1
ATagParams.data = parameters:allParams
target.data = parameters:target
title.data = parameters:title
extTarget.data = parameters:target
}
forceLink = 1
}
}
My idea to include the L parameter was also unsuccessful.
...
additionalParams.wrap = &L={GP:L}&tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]=|
additionalParams.insertData = 1
...
Meanwhile I think it is a bug, so I create this ticket here. I hope someone can help or confirm that it is a bug.
Updated by Georg Ringer over 2 years ago
- Status changed from New to Needs Feedback
can you please test this in 11? I tested the following use cases
- Default content element
- Link to news in default language: works
- Link to news in 2nd language: works
- Translated content
- Link to news in default language: links to the translated news. IMO ok as otherwise after a translation the link would need to be adopted
- Link to news in 2nd language: doesn't work
There won't be any change for 10 in that regard because it is not that critical.
Updated by Georg Ringer over 2 years ago
- Related to Bug #97806: Linkhandler to translated records does not work on translated pages added
Updated by Martin R. Krause over 2 years ago
There won't be any change for 10 in that regard because it is not that critical.
I would considere this critical, as all links to translated records/pages that have fallbacks are gone! But those a very commen (e.g. pt_BR or en_US overlays, that hardly have translation records).
Updated by Martin R. Krause over 2 years ago
if ($languageAspect->doOverlays()) {
$overlay = $tsfe->sys_page->getRecordOverlay(
$databaseTable,
$record,
$languageAspect->getContentId(),
$languageAspect->getLegacyOverlayType()
);
if (empty($overlay['_LOCALIZED_UID'])) {
$record = 0;
}
}
This whole code DatabaseRecordLinkBuilder.php:58ff is a mystery. We load the overlay (which is expensive!) just to check that it exists, but only if we want to do overlay - which means that we work based on the default language anyways - then why check for the overlay record at all? Just link to record with its default uid - always.
Updated by JAKOTA Design Group GmbH over 2 years ago
Hi,
this bug can also be found in Typo3 version 11.
I've managed to resolve it by replacing
typo3/sysext/frontend/Classes/Typolink/DatabaseRecordLinkBuilder.php
Line 56-68
$languageAspect = $tsfe->getContext()->getAspect('language');
if ($languageAspect->doOverlays()) {
$overlay = $tsfe->sys_page->getRecordOverlay(
$databaseTable,
$record,
$languageAspect
);
if (empty($overlay['_LOCALIZED_UID'])) {
$record = 0;
}
}
with
$tableControl = $GLOBALS['TCA'][$databaseTable]['ctrl'] ?? [];
if (!empty($tableControl['languageField'])) {
if ($record[$tableControl['languageField']] != 0 && !empty($record[$tableControl['transOrigPointerField']])) {
$record = $tsfe->sys_page->checkRecord($databaseTable, $record[$tableControl['transOrigPointerField']]);
}
}
Please have a look
Thanks
Updated by JAKOTA Design Group GmbH over 2 years ago
To catch records with language all -1 the line
if ($record[$tableControl['languageField']] != 0 && !empty($record[$tableControl['transOrigPointerField']])) {
from my patch needs to be changed to
if ($record[$tableControl['languageField']] > 0 && !empty($record[$tableControl['transOrigPointerField']])) {
Updated by Markus Klein over 2 years ago
Just link to record with its default uid - always
This was the case in old TYPO3 versions. You linked to the default language UID and the L-parameter defined the language.
That's where this comes from. (I'm very sure).
Updated by JAKOTA Design Group GmbH over 2 years ago
- TYPO3 Version changed from 10 to 11
- PHP Version changed from 7.4 to 8.0
Updated Typo3 Version to 11 as this is not working here too.
Updated by Markus Klein over 2 years ago
- TYPO3 Version changed from 11 to 10
We usually set the lowest version which is affected and might still gets patched. So v10 is okay in this case
Updated by Oliver Hader over 2 years ago
- Sprint Focus set to On Location Sprint
Updated by Benni Mack over 1 year ago
- Sprint Focus deleted (
On Location Sprint)
Updated by Astrid Haubold over 1 year ago
- Related to Story #101565: Frontend related translation issues added