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

Apply section background image in all languages

Started by Djordje 8 years ago · 1 replies · 441 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 Thomas, 1 week ago
2 60 16 hours ago
Support · by Anna, 3 days ago
2 66 19 hours ago
Support · by Justin Young, 20 hours ago
1 34 20 hours ago
Support · by Duc , 1 week ago
2 70 6 days ago
Support · by Colin Hume, 1 week ago
2 61 6 days ago