How to use constants with conditions in typoscript
TYPO3 is a free and open source content management system as well as a Model–view–controller (MVC) Web Application Development framework written in PHP. It is released under the GNU General Public License and it can run on Apache or IIS on top of Linux, Microsoft Windows, OS/2 or Mac OS X.
TypoScript is a declarative language like HTML and Javascript used to configure extensions and the template engine.
A problem that I encountered on a project was to put a condition in the template setup with a constant declared in the Constants fields. Oddly, it didn’t work the old fashion way. After spending some time and researching the web, I’ve discovered there’s a way to use constants with conditions. The following code checks if the constant named condition is 1 or 0, followed by some code.
[code="typoscript"]
[globalVar = LIT:1 = {$x}]
...
[else]
...
[/code]
Where $x is the constant that you want to check for its value. For more imformations about conditions in typoscript you can find in the Typo3 documentation or more specifically here: http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/4/1/


Tags: 



2 Responses
June 25, 2010 1
It was very interesting for me to read that blog. Thank you for it. I like such themes and anything that is connected to this matter. I definitely want to read more soon. BTW, rather good design this blog has, but what do you think about changing it once in a few months?
Kate Meetington
June 19, 2011 2
Thanks for this. Finding this page before digging into other sources sure saved me a lot of time. Works great :)
Leave a Reply