Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

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

Started by Muut Archive 9 years ago · 1 replies · 488 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 1323 9 years ago
Archive · by Muut Archive, 9 years ago
2 920 9 years ago
Archive · by Muut Archive, 9 years ago
2 4048 9 years ago
Archive · by Muut Archive, 9 years ago
1 2924 9 years ago
Archive · by Muut Archive, 9 years ago
3 1106 9 years ago