Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Is there any way to pass in a variable to a partial?

Started by Muut Archive 9 years ago · 1 replies · 595 views
9 years ago

Hi
I want to pass over "dark" or "light" into my navigation partial, and was wondering is there is a way to pass this via the include? Something like the following...

{% include 'partials/footer.html.twig', 'dark' %}

Which I could then access on the partial page and include in the elements class.

Thanks in advance.
Alan

9 years ago

Hello,

Example find into antimatter theme :

TWIG
{% include 'partials/blog_item.html.twig' with {'blog':page.parent, 'truncate':false} %}

Into blog_item.html.twig

TWIG
  <a href="{{ blog.url|rtrim('/') }}/tag{{ config.system.param_sep }},{{ tag }}" class="p-category">{{ tag }}</a>

Hope that could help.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 2273 9 years ago
Archive · by Muut Archive, 9 years ago
2 1495 9 years ago
Archive · by Muut Archive, 9 years ago
2 4742 9 years ago
Archive · by Muut Archive, 9 years ago
1 3552 9 years ago
Archive · by Muut Archive, 9 years ago
3 1618 9 years ago