Search code examples
typo3fallback

TYPO3: Show content from a fixed page if there’s no content on current page


I would like to show content from a fixed page if there’s no content on current page.

An example: On the mainpage (pid=58) In the right col (colPos=31) I have a news plugin with the latest item. On subpages, it’s possible to insert content in the right col (colPos=31). It could be images,text etc. BUT, if the right col is empty I would like to show the news plugin from the mainpage as a fallback option.

This is my TypoScript, but it doesn’t work. Default content from mainpage are not showed, if there's no content from current page.

lib.rightCol-1 = COA
lib.rightCol-1 {
    10 = COA
    10 {
        ## Get content from current page. 
        10 = COA
        10 < styles.content.get 
        ## Get content from colPos 31
        10.select.where = colPos=31 
        if.isTrue.current = 1 

        20 = CONTENT
        20 {
            ## IF no content on current page show content from mainpage
            stdWrap.if.isTrue.current = 1
            stdWrap.if.negate = 1
            table = tt_content
            select {
                ## Get content from mainpage
                pidInList = 58
                where = colPos=31
                orderBy = sorting
                languageField = sys_language_uid
            }
        }
    }
}

Solution

  • Thanks for answer but I couldn't get it to work. Instead this worked:

    lib.rightCol-1 = CONTENT
    lib.rightCol-1 < styles.content.get
    lib.rightCol-1.select.where = colPos=31
    lib.rightCol-1 {
        stdWrap.ifEmpty.cObject = CONTENT
        stdWrap.ifEmpty.cObject {
        table = tt_content
        select {
            pidInList = 58
            orderBy = sorting
            where = colPos = 31
            languageField = sys_language_uid
            }
        }
    }