Hey everybody,
I would like to add a global variable to my twig templates based on a config setting. I’m aware that I could just check the config setting in each template, but I would like a solution that’s easier to use and maintain.
I found this bit in the Event Hooks page in the docs:
onTwigSiteVariables
Where Twig processes the full site template hierarchy. This is where you should add any variables to Twig that need to be available to Twig during this process.
Sounds like this is what I want, and I have put a function in my theme.php file – but how do I actually add a variable to twig here?
Thanks for your ideas and time!