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

Template problem with background image

Started by Muut Archive 10 years ago · 1 replies · 406 views
10 years ago

I'm trying to show a background image in my template like this:

TWIG
{% set back_image = theme_url ~ '/images/' ~ page.header.background.image  %}

<div class="modular-row callout" style="padding-bottom: 60px; background-image: {{ back_color }}  url({{ back_image }}) repeat left top;">

But GRAV generates this output with the image name missing:

TXT
<div class="modular-row callout" style="padding-bottom: 10px; padding-top: 30px; background: #00ff00 url(/user/themes/gravitas/images/) repeat left top;">

while showing the content of {{ back_image }} clearly output this:

TXT
background: #00ff00 url(/user/themes/gravitas/images/lillies.gif) repeat left top; 

What's wrong here?

10 years ago

This drives me mental now.

Two user defined parameters in the page.header

YAML
background:
    image: 'pattern.png'
    color: '#440000'

I want to show this color/image as a div background.
But it simply won't work. Please help.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1361 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1123 9 years ago