TYPO3: check if current page is translated by typoscript

本秂侑毒 提交于 2021-01-28 09:03:22

问题


For the generation of the canonical tag by typoscript, I need to check if the current page is translated. If not, the canonical needs to point to the url in default language.

How can I check if current page is translated by typoscript?

Language handling in my typoscript config:

sys_language_overlay = 1
sys_language_mode = content_fallback

回答1:


If anyone is interested, I have worked out a solution to my task: Render the canonical url in default language if there is no translation for the current page (content_fallback)

page.headerData.10 = COA
page.headerData.10 {
    10 = LOAD_REGISTER
    10.isPageTranslated.cObject = CONTENT
    10.isPageTranslated.cObject {
        table = pages
        select {
            selectFields = plo.sys_language_uid
            pidInList = {$config.rootPid}
            join = pages_language_overlay plo ON plo.pid = pages.uid            
            where = plo.pid = ###pid### AND plo.sys_language_uid = ###lang### AND plo.deleted = 0 AND plo.hidden = 0
            markers {
                pid.data = page:uid
                lang.data = page:sys_language_uid
            }
        }
        renderObj = TEXT
        # translation available
        renderObj {
            wrap = <link rel="canonical" href="|">
            typolink {
                parameter.data = TSFE:id
                returnLast = url
            }
            append = TEXT
            append.value (

)
        }
    }   
    20 = TEXT
    20 {
        data = register:isPageTranslated
        ifEmpty {
            # no translation available
            wrap = <link rel="canonical" href="|">
            typolink {
                parameter.data = TSFE:id
                additionalParams = &L=0
                returnLast = url
            }
            append = TEXT
            append.value (

)
        }
    }
}


来源:https://stackoverflow.com/questions/62423929/typo3-check-if-current-page-is-translated-by-typoscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!