[TYPO3-dev] EnableField and localisation
Schani
usenet at schani.com
Mon Apr 7 21:58:59 CEST 2008
is there not a function in the T3 API ?
Christian
Francois Suter schrieb:
> Hi,
>
>>> But im not able to localize my entry. Is enableFields do this part or do
>>> i use a other function for this ? This time all versions of language are
>>> displayed in FE.
>>
>> you have to select the correct(=actual?) language by yourself:
>> just enhance your WHERE-clause with:
>>
>> $where_clause .= ' AND sys_language_uid = '
>> .$GLOBALS['TSFE']->sys_language_uid;
>
> Actually if you use the full possibilities of TYPO3's translation system
> (i.e. your table has all the necessary fields for localisation), it is a
> bit more complicated than that.
>
> The basic idea is that you want to get the records for the default
> language and then overlay the translation on them. If you want to be
> complete, you also need to get the records that are valid for all
> languages (the language field = -1) and the languages is the current
> language (if it's not the default one) that have no original in the
> default language (e.g. your site is in English by default, and a record
> exists only in German).
>
> Furthermore rather than hardcoding the name of the language field in
> your SQL query, you should use the definition from the TCA.
>
> In the end, you should have something like:
>
> // Add selection of language (if activated)
> // There are two main cases:
> //
> // - if the overlay mechanism is activated and the reference table
> has translation information,
> // we must get the original elements and the translation will be
> overlaid afterwards
> // - if not, then we get directly the elements in the right language
>
> if (!empty($GLOBALS['TCA']['your_table_name']['ctrl']['languageField'])) {
> if (isset($GLOBALS['TSFE']->sys_language_contentOL) &&
> isset($GLOBALS['TCA']['your_table_name']['ctrl']['transOrigPointerField']))
> {
> $languageCondition =
> $GLOBALS['TCA']['your_table_name']['ctrl']['languageField'].' IN
> (0,-1)'; // Default language and "all" language
>
> // If current language is not default, select elements that exist only
> for current language
> // That means elements that exist for current language but have no
> parent element
>
> if ($GLOBALS['TSFE']->sys_language_content > 0) {
> $languageCondition .= ' OR
> ('.$GLOBALS['TCA']['your_table_name']['ctrl']['languageField']." =
> '".$GLOBALS['TSFE']->sys_language_content."' AND
> ".$GLOBALS['TCA']['your_table_name']['ctrl']['transOrigPointerField']."
> = '0')";
> }
> }
> else {
> $languageCondition =
> $GLOBALS['TCA']['your_table_name']['languageField']." =
> '".$GLOBALS['TSFE']->sys_language_content."'";
> }
> }
>
> HTH
>
More information about the TYPO3-dev
mailing list