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

Reference asset in theme configuration file/options

Solved by Hugh Barnes View solution

Started by Carlos 8 years ago · 2 replies · 647 views
8 years ago

Hello,

I am very relieved Grav exists because I was beginning to dislike the direction Wordpress was heading (bloated html and completely unnecessary javascript scripts loaded)..

Anyway, hopefully I'm not wasting anyone's time with these simple questions..

What is this url type called? --> theme://images/logo.png

How can I call this type of reference url within my theme's configuration file? My aim is for something as follows in a file called themes/my-first-theme/my-first-theme.yaml

YAML
dropdown:
  enabled: true
logo: theme://images/logo.png

So that within twig, I can use {{ theme_config.logo }}

8 years ago Solution

I feel like I am doing too many guessed replies lately, but it should be helpful to know that these are called PHP streams.

I don't have a strong grasp on them yet, but I see examples in the docs that I follow successfully. Combined with the Twig url function, I think if you do this in your frontmatter, you should be able to access it with {{ theme_config.logo }}:

TWIG
logo: "{{ url(theme://images/logo.png) }}"
process:
  twig: true

or maybe just logo: {{ theme://images/logo.png }} + process.twig and then reference your image URL with {{ url(theme_config.logo) }} if you want more flexibility with your image.

8 years ago

Since I just had to research this ...

YAML
logo: 'theme://images/example.svg'

And in Twig:

TWIG
<img src="{{ url(theme_config.logo) }}">

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by stuart young, 2 weeks ago
3 251 2 weeks ago
Themes & Styling · by Sebadamus, 3 weeks ago
5 317 3 weeks ago
Themes & Styling · by martynfoster735, 4 weeks ago
1 310 4 weeks ago
Themes & Styling · by Justin Young, 1 month ago
1 348 1 month ago
Themes & Styling · by Slebeig, 2 months ago
4 474 2 months ago