Project

General

Profile

Actions

Feature #59833

closed

levelmedia translation fallback

Added by Tizian Schmidlin about 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Content Rendering
Target version:
-
Start date:
2014-06-24
Due date:
% Done:

0%

Estimated time:
PHP Version:
5.3
Tags:
Complexity:
Sprint Focus:

Description

Hello there,

I recently run into a use case that was not covered by the standard TYPO3 features: translation fallback for levelmedia.

Explanation: we set up a new field for pages that is used to set a banner on the page. This banner may change according to the current page language (since banner may contain text in different languages). Now the customer didn't have the time to replace all the banners on time, so we needed a fallback to the standard translation.

Sadly, this wasn't covered by levelmedia yet, also the l10n_mode 'mergeIfNotBlank' didn't do the trick, so I developed the following patch:

in TYPO3 4.5.x: typo3/sysext/cms/tslib/class.tslib_content.php:5261
in TYPO3 6.2.x: typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php:5426

case 'levelfield':
    $keyP = t3lib_div::trimExplode(',', $key);
    $nkey = $this->getKey($keyP[0], $GLOBALS['TSFE']->tmpl->rootLine);
    $rootLine = $GLOBALS['TSFE']->tmpl->rootLine;
    /** cab st: 2014-06-23: add an additional parameter for levelfield so you can take the value from the
     * original page data. If there wasn't any, check the other levels for values. As soon as a value is found, we
     * break the loop.
     */
    if($keyP[3] == 'from_original') {

        for($i = $nkey; $i >= 0; $i--) {
            if(empty($rootLine[$i][$keyP[1]])) {
                // try to get the original
                $newRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
                    '*',
                    'pages',
                    'uid = ' . $rootLine[$i]['uid']
                );

                if(!empty($newRow[$keyP[1]])) {
                    $rootLine[$i][$keyP[1]] = $newRow[$keyP[1]];
                    break;
                }                                    
            } else {
                // we already are on a superior level that has content, so no untranslation needed
                break;
            }
        }
    }
    $retVal = $this->rootLineValue($nkey, $keyP[1], strtolower($keyP[2]) == 'slide', $rootLine);
    /** cab st end */
break;

This patch is completely backwards compatible since you have to add a parameter to the levelfield after slide.

Best Regards

Tizian


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #44312: Sliding levelmedia not working for alternate languages in 6.0.0Closed2013-01-04

Actions
Related to TYPO3 Core - Bug #65863: content_fallback / mergeIfNotblank fails with content slide, pageOverlayFields is ignoredClosedJo Hasenau2015-03-20

Actions
Actions

Also available in: Atom PDF