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

Apply section background image in all languages

Started by Djordje 8 years ago · 1 replies · 543 views
8 years ago

This is the code that works:

TWIG
{% if header.background_images.top_section is not empty %}
{% set image = header.background_images.top_section|first %}
{% set image_url = url(image.path) %}
.top-bg {
     background-image: url({{ image_url }}) !important;
 }

Currently, I have to upload the background image separately in each language...
Is there a way for the background image to be automatically applied in all languages?

8 years ago

You could try to load the default language page in twig and extract the data from there, instead of the page.find function you will have to use the pages.dispatch function to avoid language redirection. This means you only have to specify the background image via selection for the default page.

Another possibility consists in synchronizing some of the header data between the different language versions. This can be done via function that hooks into onAdminSave onAdminAfterSave.

A language synchronization plugin for frontmatter data is one of the missing GRAV plugins...

Suggested topics

Topic Participants Replies Views Activity
Support · by Paul Hodges, 4 weeks ago
19 485 5 days ago
Support · by Lauw, 7 days ago
2 99 7 days ago
Support · by Anna, 3 weeks ago
4 426 1 week ago
Support · by gtx, 4 weeks ago
4 377 3 weeks ago
Support · by Anna, 1 month ago
9 484 3 weeks ago