Search code examples
typo3typoscript

Typo3 inherit data when if is true


I generate an lib.content with the current content but i want to add it only if the following if statement will be true, otherwise not/empty:

lib.content = COA
lib.content{
    10 < styles.content.get
    10.stdWrap.cObject.if{
        value.data = DB:pages:{page:uid}:nav_hide
        value.data.insertData = 1
        equals = 1
    }
}

is this possible or where's the error in the syntax?

Version of Typo3 is 10.4


Solution

  • You need to use "insertData" twice, because it replaces {page:uid} with the UID (e.g. 5), but it keeps the rest DB:pages:5:nav_hide.

    The rest DB:pages:5:nav_hide needs to be "data inserted" again, so the trick is to use wrap3.

    Solution:

    lib.content = COA
    lib.content {
        10 < styles.content.get
        10.stdWrap.cObject.if {
            // Replaces page:uid
            value.dataWrap = DB:pages:{page:uid}:nav_hide
            // Wraps curly brackets around DB:pages:5:nav_hide
            value.wrap3 = {|}
            // Replaces DB:pages:5:nav_hide with the nav_hide value
            value.insertData = 1
            equals = 1
        }
    }