Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Item template inherits variable from blog template, even if it is defined to false

Started by Pedro M 3 years ago · 0 replies · 704 views
3 years ago

Hi.

In blog template and item template I have the sidebar variable in this way (same as the Quark theme):

TWIG
{% set show_sidebar = header_var('show_sidebar', [page, blog])|defined(false)  %}

If I define that variable in the blog as true, the child pages (item type) inherit that value, although on these pages the filter |defined is set to false.

If I do not define anything, by default, the sidebar will be displayed on the blog page and on the item pages, it will not be displayed, that is, the |defined filter does have an influence.

It is very annoying to have to set the show_sidebar variable to false, explicitly in each blog article.
Is there a way to avoid this inheritance between item type pages with respect to their parent blog?

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 24 hours ago
2 40 17 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago