Is it possible to compare variables in TypoScript? If it is possible – then how?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I struggled with the very same issue, so here is what I found out. I was trying to include a plugin, but only if a certain TypoScript configuration variable was already set, which isn’t possible using TypoScript conditions, because these don’t have access to TypoScript variables!
So the way to go really is the ominous
if-function. The documentation says the following:What they do not mention is, that, if the
if-function returnsfalse, the Element in question is just not displayed/executed or whatever TypoScript actually does, for example:This TEXT-element would never be displayed, because the condition does not evaluate to true. The following however, would be displayed:
if.valuealways holds the value you are comparing to, and then there are a bunch of property you may use to compare another value to it.The only good example in the documentation is this one:
But beware… these properties are not available on any element type (
USER_INTfor example, does not have them).What I did to workaround that problem was to wrap the
USER_INTin aCOAas follows: