Project

General

Profile

Actions

Feature #88137

closed

Create multi-step fallback for content and arbitrary records

Added by Benni Mack over 5 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Localization
Target version:
-
Start date:
2022-07-13
Due date:
% Done:

100%

Estimated time:
(Total: 0.00 h)
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

It should be possible to show content of language=2, and if it is not translated, use the fallback chain to language=1 and stop there.


Subtasks 1 (0 open1 closed)

Feature #97926: Use LanguageAspect in Extbase PersistenceClosedBenni Mack2022-07-13

Actions

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #86762: Site-Configuration defined language fallbacks not workingClosedAnja Leichsenring2018-10-26

Actions
Related to TYPO3 Core - Bug #91781: Language Fallback Chain is not working in custom ExtensionClosed2020-07-10

Actions
Actions #1

Updated by Benni Mack over 5 years ago

  • Related to Bug #86762: Site-Configuration defined language fallbacks not working added
Actions #2

Updated by Benni Mack over 5 years ago

Also see Daniel's comment / code snippet in the other issue

Actions #3

Updated by David Bruchmann over 5 years ago

Hi Benni,

just pulled news master-dev and tested a bit.
Good news is that without RouteEnhancer everything is working fine, also if I use only the uid in RouteEnhancer.

Fine is related to my (known) personal scenario:
language 0 no fallback
language 1 no fallback
language 2 fallback to language 1

In languages 0 and 1 the slugs are created correct if I use news_title in RouteEnhancer - that's working well.
In language 2 the titles are not produced (by extension seo?) but instead the uids are appended to the configured path, but this is not resolved by EXT:news and results in a 404 error.
So the URLs look like this: https://domain.com/a-lactu/article/255

So my issue is about the RouteEnhancer and the language-fallback of the titles of the news.
Now I don't know if the RouteEnhancer just has to be configured different or if some extensions like seo, backend, frontend, etc. have to be changed (or even something in news).

Here still my desired setup for the news-titles (categories, etc. I leave away here):

routeEnhancers:
  News:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      -
        routePath: '/{news_title}'
        _controller: 'News::detail'
        _arguments:
          news_title: news
    defaultController: 'News::list'
    requirements:
      news_title: '^[a-zA-Z0-9].*$'
      page: \d+
    aspects:
      news_title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment

and here the working setup with uids only:

routeEnhancers:
  News:
    type: Extbase
    extension: News
    plugin: Pi1
    routes:
      -
        routePath: '/{news_uid}'
        _controller: 'News::detail'
        _arguments:
          news_uid: news
    defaultController: 'News::list'
    aspects:
      news_uid:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: uid

Actions #4

Updated by Riccardo De Contardi about 5 years ago

  • Category set to Localization
Actions #5

Updated by Susanne Moog almost 5 years ago

  • Sprint Focus set to On Location Sprint
Actions #6

Updated by David Hedden almost 4 years ago

For folks that find this and want to impelement a solution for Typo3 9.5.
Typo3DbQueryParser and PageRepository via XCLASS, fallback can be enabled by settings languageAspect to true for a table.

This solution works for 1 level Typo3DbQueryParser.php

This works for multiple levels Typo3DbQueryParser.php

But its with a raw statments. Should be a bit faster, since overlaying happens in 1 Statement.

PageRepository.php

Based on solution from David Bruchmann
Difference is that rows get discarded if default (0) is not defined in fallback chain.

Actions #7

Updated by Gerrit Code Review almost 4 years ago

  • Status changed from New to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #8

Updated by Gerrit Code Review almost 4 years ago

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67894

Actions #9

Updated by Gerrit Code Review almost 4 years ago

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67895

Actions #10

Updated by Gerrit Code Review almost 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #11

Updated by Gerrit Code Review almost 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #12

Updated by Gerrit Code Review almost 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #13

Updated by Gerrit Code Review almost 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67895

Actions #14

Updated by Gerrit Code Review almost 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #15

Updated by Gerrit Code Review almost 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67895

Actions #16

Updated by Gerrit Code Review almost 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67895

Actions #17

Updated by Gerrit Code Review almost 4 years ago

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67957

Actions #18

Updated by Gerrit Code Review almost 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67895

Actions #19

Updated by Gerrit Code Review almost 4 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67895

Actions #20

Updated by Gerrit Code Review almost 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #21

Updated by Gerrit Code Review almost 4 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #22

Updated by Gerrit Code Review almost 4 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #23

Updated by Gerrit Code Review almost 4 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #24

Updated by Gerrit Code Review over 3 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #25

Updated by Simon Praetorius over 3 years ago

We recently experienced this bug in a client project and developed a temporary workaround that works in our case. Maybe this is helpful for somebody:

config.yaml:

    aspects:
      news-title:
        type: LanguageFallbackPersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment

ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['aspects']['LanguageFallbackPersistedAliasMapper'] =
    \Sitegeist\Sitepackage\Routing\Aspect\LanguageFallbackPersistedAliasMapper::class;

LanguageFallbackPersistedAliasMapper.php:
[...]
class LanguageFallbackPersistedAliasMapper extends PersistedAliasMapper
{
    /**
     * @param array|null $record
     * @return array|null
     */
    protected function resolveOverlay(?array $record): ?array
    {
        $result = parent::resolveOverlay($record);

        $languageAware = $this->languageFieldName !== null && $this->languageParentFieldName !== null;
        if (!$languageAware) {
            return $result;
        }

        $languageFallbackChain = array_reverse($this->resolveAllRelevantLanguageIds());
        $pageRepository = $this->createPageRepository();

        if (!$result || $result[$this->languageFieldName] == 0 && $languageFallbackChain) {
            foreach ($languageFallbackChain as $fallbackLanguageId) {
                $result = $pageRepository
                    ->getRecordOverlay($this->tableName, $record, $fallbackLanguageId) ?: null;
                if ($result[$this->languageFieldName] == $fallbackLanguageId) {
                    break;
                }
            }
        }

        return $result;
    }
}

Note that this will lead to more SQL queries during link generation, but in our case the correct links were more important.

Actions #26

Updated by Gerrit Code Review over 3 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #27

Updated by Gerrit Code Review about 3 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #28

Updated by Gerrit Code Review about 3 years ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #29

Updated by Gerrit Code Review about 3 years ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #30

Updated by Gerrit Code Review about 3 years ago

Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #31

Updated by Gerrit Code Review about 3 years ago

Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #32

Updated by Gerrit Code Review about 3 years ago

Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #33

Updated by Gerrit Code Review about 3 years ago

Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #34

Updated by Gerrit Code Review about 3 years ago

Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #35

Updated by Gerrit Code Review about 3 years ago

Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #36

Updated by Gerrit Code Review about 3 years ago

Patch set 20 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #37

Updated by Gerrit Code Review about 3 years ago

Patch set 21 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #38

Updated by Gerrit Code Review about 3 years ago

Patch set 22 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #39

Updated by Gerrit Code Review about 3 years ago

Patch set 23 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #40

Updated by Gerrit Code Review about 3 years ago

Patch set 24 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #41

Updated by Gerrit Code Review almost 3 years ago

Patch set 25 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #42

Updated by Gerrit Code Review almost 3 years ago

Patch set 26 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #43

Updated by Gerrit Code Review almost 3 years ago

Patch set 27 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #44

Updated by Gerrit Code Review almost 3 years ago

Patch set 28 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #45

Updated by Gerrit Code Review over 2 years ago

Patch set 29 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #46

Updated by Gerrit Code Review over 2 years ago

Patch set 30 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #47

Updated by Gerrit Code Review about 2 years ago

Patch set 31 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #48

Updated by Gerrit Code Review about 2 years ago

Patch set 32 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #49

Updated by Oliver Hader about 2 years ago

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

Updated by Gerrit Code Review almost 2 years ago

Patch set 33 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #51

Updated by Gerrit Code Review almost 2 years ago

Patch set 34 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #52

Updated by Gerrit Code Review almost 2 years ago

Patch set 35 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #53

Updated by Gerrit Code Review almost 2 years ago

Patch set 36 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #54

Updated by Gerrit Code Review almost 2 years ago

Patch set 37 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #55

Updated by Gerrit Code Review almost 2 years ago

Patch set 38 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #56

Updated by Gerrit Code Review almost 2 years ago

Patch set 39 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #57

Updated by Gerrit Code Review almost 2 years ago

Patch set 40 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67893

Actions #58

Updated by Anonymous almost 2 years ago

  • Status changed from Under Review to Resolved
Actions #59

Updated by Benni Mack almost 2 years ago

  • Status changed from Resolved to Closed
Actions #60

Updated by Benni Mack 9 months ago

  • Related to Bug #91781: Language Fallback Chain is not working in custom Extension added
Actions

Also available in: Atom PDF