flyntwp / flynt-starter-theme

The starter theme for building Flynt projects.
MIT License
69 stars 4 forks source link

Is it possible to check if an area exists in a twig template ? #285

Closed bdebrie closed 5 years ago

bdebrie commented 5 years ago

If I remember it correctly using {% if area('mainSidebar') %} in a twig template file used to work, but with the latest version of the theme this isn't doing anything.

I made a quick workaround on my current project by adding a new Twig Simple Function areaExists in Flynt\Features\TimberLoader. Is this something that I should put in a pull request ? Did you ever have this use case, and if yes, what is your approach to solve this ?

Cheers

domtra commented 5 years ago

have you tried {% if area('mainSidebar') is empty %}? if this does not work either, check what the output of {{ dump(area('mainSidebar')) }}. if none of this leads to a result, a pr would be welcome.

bdebrie commented 5 years ago

{% if area('mainSidebar') is not empty %} works like a charm

Thank you sensei !