Search code examples
typo3typo3-12.x

Category translation in TYPO3 not working as expected


TYPO3 12, PHP 8.2. I am trying to get the categories of my posts for some icons. Since i found no way of getting the categories directly in fluid i thought i'd give typoscript a try. This works fine in the base language, however the translations are empty. I have translated

  • the category container page
  • all categories
  • my page and it's content of course, the content itself is in the right language in the frontend

This is how i envoke it in fluid:

{f:cObject(typoscriptObjectPath: 'lib.categories', data:'{recordUid: data.uid}')}

This is my typoscript CONTENT object:

    lib.categories = CONTENT
    lib.categories {
            table = sys_category
            select {
                # set correct id for sys folder
                pidInList = 652
                selectFields = title, uid
                join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid    
                where.data = field:recordUid
                where.intval = 1
                where.wrap = uid_foreign=|
                languageField = sys_language_uid
            }

            renderObj = COA
            renderObj {
                1 = TEXT
                1 {
                    value = <li class="refcat refcat-{field:uid}"><span>{field:title} </span></li>                   
                    insertData = 1
                }
            }
        }

i have even checkd the db, my content elements objects have the exact same categories and settings in both languages. Any ideas? Can this be done in Fluid or maybe even with a userFunc? Thanks


Solution

  • finally got it to work, just leaving out the languagefield is not enough, since TYPO3 7.4 you need to explicitly set it to 0

    https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/7.4/Feature-68191-TypoScriptSelectOptionLanguageFieldIsActiveByDefault.html

    so this is the code that grabs the correct categories from the base language

    table = sys_category
            select {
                # set correct id for sys folder
                pidInList = 652
                selectFields = title, uid
                join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
                where.data = field:recordUid
                where.intval = 1
                where.wrap = uid_foreign=|
                languageField = 0
            }