Issue Bug Closed

#97777linkhandler config.recordLinks for news plugin (as example) not working if news article is translated

Markus Eckert 06/15/22, 10:46 updated 02/07/26, 09:33

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.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 14

  1. Georg Ringer commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2022-06-23T13:03:13+00:00" > 06/23/22, 13:03 </span>

    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.

  2. Martin R. Krause commented <span data-processor="relativetime" data-value="2022-06-30T12:30:27+00:00" > 06/30/22, 12:30 </span>

    > 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).

  3. Martin R. Krause commented <span data-processor="relativetime" data-value="2022-06-30T14:42:38+00:00" > 06/30/22, 14:42 </span>

     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.

  4. JAKOTA Design Group GmbH commented <span data-processor="relativetime" data-value="2022-07-15T22:31:34+00:00" > 07/15/22, 22:31 </span>

    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

  5. JAKOTA Design Group GmbH commented <span data-processor="relativetime" data-value="2022-07-16T08:05:21+00:00" > 07/16/22, 08:05 </span>

    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']])) {
  6. Markus Klein commented <span data-processor="relativetime" data-value="2022-07-18T11:21:32+00:00" > 07/18/22, 11:21 </span>

    > 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).

  7. JAKOTA Design Group GmbH commented and changed TYPO3 Version 10 11 PHP Version 7.4 8.0 <span data-processor="relativetime" data-value="2022-07-19T23:14:59+00:00" > 07/19/22, 23:14 </span>

    Updated Typo3 Version to 11 as this is not working here too.

  8. Markus Klein commented and changed TYPO3 Version 11 10 <span data-processor="relativetime" data-value="2022-07-20T06:17:57+00:00" > 07/20/22, 06:17 </span>

    We usually set the lowest version which is affected and might still gets patched. So v10 is okay in this case

  9. Sven Burkert commented <span data-processor="relativetime" data-value="2026-02-07T09:15:26+00:00" > 02/07/26, 09:15 </span>

    Seems to be fixed since TYPO3 v12.
    But there, I have the opposite problem: #108894