Change template if content exists in Typo3

If you build sites with Typo3 you might want to use a smart template that uses different markup for different pages. Of course you can define as many templates as you like in Typo3. But what if you want to use a two and a three-column layout, depending on if content in one column exists, and if you don't know in advance if there is content in that column? The solution is rather easy, do something like in this example:

# Add a float if we have content in column 2
foo = COA
foo {
	wrap = 
	200 = CONTENT
	200 {
		table = tt_content
		select {
			where = colPos = 2
			orderBy = sorting
	# conditional to test if content exists in column
	if.isTrue.numRows {
		# check current page page
		pidInList = this
		# in the table tt_content
		table = tt_content
		# colPos = 2 (right)
		select.where = colPos=2
This example shows a very simple flexible template using a float.



Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.
DjangoPythonBitcoinTuxDebianHTML5 badgeSaltStackUpset confused bugMoneyHackerUpset confused bugX.OrggitFirefoxWindowMakerBashIs it worth the time?i3 window managerWagtailContainerIrssiNginxSilenceUse a maskWorldInternet securityPianoFontGnuPGThunderbirdJenkinshome-assistant-logo