How do I get current FE language in where clause in DatabaseQueryProcessor in TYPO3?

37 views Asked by At

I want a condition to get data, language wise in FE. I don't know how to get current language uid in a where clause in DatabaseQueryProcessor.

I tried different approaches to achieve this, but it doesn't work for me. One of them is:

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
    // some configuration
    where.wrap = sys_category.sys_language_uid = TSFE:language
    // Also
    where.wrap = sys_category.sys_language_uid = {FE:language}
    // Also
    where.wrap = sys_category.sys_language_uid = {GP:L}
    // Also
    where.wrap = sys_category.sys_language_uid = siteLanguage:navigationTitle
    // Also
    where.wrap = sys_category.sys_language_uid = TSFE:sys_language_uid
}

I know one alternative solution for this will be typoscript condition language wise. But I want this dynamic with every possible language of typo3.

2

There are 2 answers

0
Geee On

Did you tried this way?

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
        ...
        where.intval = 1
        where.dataWrap = sys_category.sys_language_uid={TSFE:language} OR sys_category.sys_language_uid=={FE:language}
        ...
}

I'm not sure, if typoscript handle sys_category.sys_language_uid={TSFE:language} or sys_category.sys_language_uid=TSFE:language without curly braces.

0
keval pandya On

As per my understanding, You need to pass the current language ID in your SQL query, right? And if Yes, then TYPO3 default passes it and if you want to disable it then you can use this doc - https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Functions/Select.html#languagefield

Just try to debug your SQL query and you can easily find the all your question answers in debug query :)

Thank you!