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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

How to access theme blueprint attributes like author.name

Solved by pamtbaau View solution

Started by Ace A. 4 years ago · 3 replies · 372 views
4 years ago

I am making a base Grav theme, and I am doing something like this:

TWIG
<p>{{ theme.name }} made with ❤️ by {{ theme.author.name }}</p>

But I could not get it to work in my theme partials twig file despite what the docs say. I can only access config.system.pages.theme, which is a different yaml file altogether.

No results are showing online. I've also been checking multiple themes, and it appears every theme, including official grav themes, that I've checked hardcode this information.

4 years ago

There is no way to access blueprint attributes from the objects in _context.

however, I think I am close. In the partials folder in the admin plugin, the theme object behaves the same way as in the theme configuration docs. If I am not mistaken, these lines are responsible for the behavior I am looking for:

TWIG
#user/plugins/admin/themes/grav/templates/partials/theme.html.twig

  {% set theme = admin.themes[admin.route] %}
  {% set blueprints = theme.blueprints() %}

Either there is a function i have to define in themename.php to access the theme blueprint attributes or there is a predefined function somewhere in the admin plugin or in Grav/Common that will allow this to happen.

4 years ago Solution

@gravnoobie,

Try {{ grav.theme.name }} and {{ grav.theme.author.name }} in your Twig template.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
3 92 3 hours ago
Support · by Anna, 3 days ago
2 94 24 hours ago
Support · by Justin Young, 1 day ago
1 62 1 day ago
Support · by Duc , 1 week ago
2 98 6 days ago
Support · by Colin Hume, 1 week ago
2 91 6 days ago