Menü schliessen
Created: March 16th 2012
Last updated: May 1st 2020
Categories: Typo3
Author: Marcus Fleuti

Typo3 if conditional to choose a page template based on the content in specific column

Tags:  Typo3
Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

Howto switch between Typo3 page templates based on content in a column

This comes very handy when you want to display an element on the website only when there is content for it. This can be done with the following typoscript code:

temp.maintemplate = COA
temp.maintemplate {
    # if there is content in the right col
    10 = COA
    10 {
        if.isTrue.numRows < styles.content.getRight
        10 = TEMPLATE
        10 {
            template = FILE
            template.file = fileadmin/2cols.html
        }
    }
    # if there is NO content in the right col
    20 = COA
    20 {
        if.isFalse.numRows < styles.content.getRight
        10 = TEMPLATE
        10 {
            template = FILE
            template.file = fileadmin/1col.html
        }
    }
}