Hi all,
Pretty simple question here I just can’t seem to find an answer to in the archives.
Is it possible to check whether a Global Template Variable exists? Rather than just check that it’s equal or not equal to something…
Scenario: I’m writing out some tracking and Google analytics JavaScript within a website, site-wide, so I put the text in global template variables. So I have {analytics} in every template page writing my analytics JS.
Thing is we might want to turn this off sometimes. And I don’t want to delete the contents of the global variables (which would admittedly do the job) as I might want to turn it on again later.
So my idea was to just rename the global variable and thus stop it being written. (e.g. “analytics_off”). But to do this I would need to check if the variable exists before trying to write it. Something like:
{if analytics}
{analytics}
{/if}...which obviously isn’t working.
Or maybe this is just a really silly way to be going about things and someone can suggest an alternative?