Project

General

Profile

Actions

Bug #97777

open

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

Added by Markus Eckert almost 2 years ago. Updated 8 months ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
Start date:
2022-06-15
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
8.0
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 2 (1 open1 closed)

Related to TYPO3 Core - Bug #97806: Linkhandler to translated records does not work on translated pagesRejected2022-06-23

Actions
Related to TYPO3 Core - Story #101565: Frontend related translation issuesNew2023-08-03

Actions
Actions #1

Updated by Georg Ringer almost 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.

Actions #2

Updated by Georg Ringer almost 2 years ago

  • Related to Bug #97806: Linkhandler to translated records does not work on translated pages added
Actions #3

Updated by Martin R. Krause over 1 year 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).

Actions #4

Updated by Martin R. Krause over 1 year 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.

Actions #5

Updated by JAKOTA Design Group GmbH over 1 year 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

Actions #6

Updated by JAKOTA Design Group GmbH over 1 year 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']])) {
Actions #7

Updated by Markus Klein over 1 year 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).

Actions #8

Updated by JAKOTA Design Group GmbH over 1 year 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.

Actions #9

Updated by Markus Klein over 1 year 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

Actions #10

Updated by Oliver Hader over 1 year ago

  • Sprint Focus set to On Location Sprint
Actions #11

Updated by Benni Mack 8 months ago

  • Sprint Focus deleted (On Location Sprint)
Actions #12

Updated by Astrid Haubold 5 months ago

  • Related to Story #101565: Frontend related translation issues added
Actions

Also available in: Atom PDF