Project

General

Profile

Actions

Bug #42390

closed

Insert Record: l10n support

Added by Felix Kopp over 11 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Localization
Target version:
-
Start date:
2012-10-25
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
medium
Is Regression:
No
Sprint Focus:

Description

When inserting a content element of the type "Insert Record" within an multi language setup the referenced record is not fetched in the current language overlay.

Standard functionality should be to display the correct language overlay respecting the language handling configuration.


Files

typo3_insert_records.png (107 KB) typo3_insert_records.png Markus Mächler, 2019-09-23 15:24

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #82262: Content element "insert records" in an multilang environmentClosed2017-08-31

Actions
Actions #1

Updated by Felix Kopp over 11 years ago

There is a work around in the German blog at
http://typo3blogger.de/extension-insertrecordfix-turchen-23/

Perhaps there is a better solution for handling in multi language setup?

Actions #2

Updated by Lorenz Ulrich over 11 years ago

Could this be related to #42279?

Actions #3

Updated by Georg Ringer over 11 years ago

this has to be configurable because this way is also very nice to show content elements from other languages by intention!

Actions #4

Updated by Benni Mack over 11 years ago

  • Status changed from New to Accepted
  • Assignee set to Benni Mack
  • Target version set to 6.1.0
  • Complexity set to medium

Yeah, it would be nice if each CE itself has an option for that. This would make the existing feature "Insert Records" a killer feature for multilanguage setups. Shouldn't be too hard. I'll see if I can come up with sth (probably for 6.1 as Feature Freeze has already happened for 6.0).

Actions #5

Updated by Lorenz Ulrich about 11 years ago

Do you have an update concerning this feature? Is it still planned for 6.1?
FYI, Georg's extension insertrecordfix still works with 6.0.

Actions #7

Updated by Felix Kopp over 9 years ago

  • Is Regression set to No

Hey Lorenz, could send a Bugfix for TYPO3 CMS please?

Actions #8

Updated by Mathias Schreiber over 8 years ago

  • Target version deleted (6.1.0)
Actions #9

Updated by Markus Hölzle almost 7 years ago

Which config.sys_language_overlay was set here? I thought I've got the same issue, but my "config.sys_language_overlay" wasn't set.

If you set config.sys_language_overlay to "hideNonTranslated" or "1" everything works as expected (tested with TYPO3 7.6, TYPO3 8.7 and current master):

config.sys_language_overlay = hideNonTranslated

Documentation: https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#sys-language-overlay

I think we can close this issue.

Actions #10

Updated by Riccardo De Contardi over 6 years ago

  • Category set to Localization
  • Status changed from Accepted to Needs Feedback

Felix, could you test if the solution reported on comment 9 works for you? Thank you!

Actions #11

Updated by Riccardo De Contardi over 6 years ago

  • Related to Bug #82262: Content element "insert records" in an multilang environment added
Actions #12

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Needs Feedback to Closed
  • Assignee deleted (Benni Mack)

I close this for now... there has been no activity since several months, and the proposed solution (comment 9) works (I tested it with version 7.6.x)

If you think that this is the wrong decision or experience the issue again or that there is still work to be done, pleae reopen it or open a new issue with a reference to this one. Thank you.

Actions #13

Updated by Markus Mächler over 4 years ago

Riccardo De Contardi wrote:

I close this for now... there has been no activity since several months, and the proposed solution (comment 9) works (I tested it with version 7.6.x)

If you think that this is the wrong decision or experience the issue again or that there is still work to be done, pleae reopen it or open a new issue with a reference to this one. Thank you.

Setting config.sys_language_overlay to hideNonTranslated or 1 does only work for the frontend. In the backend we still see the content in the default language (tested with TYPO3 9), which is very confusing for editors, especially for editors locked to certain languages. In addition I would argue that probably even for config.sys_language_overlay = 0 we should try to get a reference to a translated record when the element is translated initially.

Actions #14

Updated by Markus Mächler over 4 years ago

  • TYPO3 Version changed from 6.0 to 9

If you wish to have a language overlay for shortcut elements even if you have config.sys_language_overlay = 0, you can install the following extension: https://github.com/visol/ext-insertrecordfix (works also with TYPO3 v8)
However this only works for the frontend. For the backend you could use the gridelements feature basic.overlayShortcutTranslation, which can be set as an extension configuration in the extension manager.
This however does not change the reference in the translated element, it will still point to the record in the default language. It does also not allow for a reference to the default language as the overlay will always happen if a translation exists.

Thus we have implemented a workaround that overwrites the records field when a shortcut element gets translated. This however does not fix existing shortcut elements with a wrong reference.

DataHandler.php

<?php
namespace Your\Extension\Hooks;

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class DataHandler {
    /**
     * @param string $status
     * @param string $table
     * @param integer $id
     * @param array $fieldArray
     * @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj
     */
    public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$pObj)
    {
        if ($status === 'new' && $table === 'tt_content' && $fieldArray['CType'] === 'shortcut') {
            //Fix localization of shortcuts to point to localized record instead of record in default language, see https://forge.typo3.org/issues/42390
            $explodedRecords = GeneralUtility::trimExplode(',', $fieldArray['records'], true);
            $newRecords = [];

            foreach ($explodedRecords as $oldRecord) {
                $tableIdSplit = BackendUtility::splitTable_Uid($oldRecord);
                $tableName = $tableIdSplit[0];
                $oldRecordUid = (int) $tableIdSplit[1];
                $newRecordUid = $oldRecordUid;

                if ($oldRecordUid > 0) {
                    $translatedRecord = BackendUtility::getRecordLocalization($tableName, $oldRecordUid, $fieldArray['sys_language_uid']);

                    if (is_array($translatedRecord[0])) {
                        $newRecordUid = (int) $translatedRecord[0]['uid'];
                    }
                }

                $newRecords[] = $tableName . '_' . $newRecordUid;
            }

            $fieldArray['records'] =  implode(',', $newRecords);
        }
    }
}

ext_tables.php

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][$_EXTKEY] = Your\Extension\Hooks\DataHandler::class;

Actions

Also available in: Atom PDF