Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FAL FileReferences aren't localized in FE

In TYPO3 6.2 in my model I have a common field for files called documents, it's ObjectStorage of \TYPO3\CMS\Extbase\Domain\Model\FileReference nothing unusual :)

The problem is on localized pages, just when I create a localized version of my obj all its fields are localized properly but not documents - it always uses a file ref(s) from default language :/ I read about unresolved bugs for this, but there's no working workaround pointed... Can any suggest me what to do?

If nothing will help I'll just write my own FileRef model, but would be great to avoid this as has several places to change.

My field in model (getter and setter are standard)

/**
 * Documents
 *
 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
 * @cascade remove
 */
protected $documents = NULL;

and in TCA:

'documents' => array(
    'exclude' => 1,
    'label' => 'Documents',
    'config' =>
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'documents',
            array('maxitems' => 999)
        ),
),
like image 493
biesior Avatar asked Oct 30 '22 17:10

biesior


1 Answers

There are two bugs in the front-end of TYPO3 if it's about overlaying translations for pages. The reason is, that this table uses a dedicated table pages_language_overlay to keep these translations.

When translating a page, the child records (file references) are not copied to the new localized record. The behavior should be the same if compared to translation a content element. Fixing this behavior will rather only be integrated in TYPO3 CMS 7 and CMS 8, see issue #78743 for progress in the next days/weeks.

If you share file references between the original language record and the translated record, meaning that the translated record does not define individual file references, then you can work around these empty file references when showing the translated page in the front-end by modifying TCA.

// put that to some TCA Overrides file, e.g.
// typo3conf/ext/my_ext/Configuration/TCA/Overrides/pages_language_overlay.php
$GLOBALS['TCA']['pages_language_overlay']['columns']['documents']['l10n_mode'] = 'exclude';

Using the exclude mode instructs TYPO3 to skip overlaying for the field documents in the front-end rendering process. The overlay process happens in PageRepository which is invoked by Extbase as well when the Page model gets reconstituted from storage.

like image 199
Oliver Hader Avatar answered Nov 23 '22 20:11

Oliver Hader