I’m looking to use a variable as a global variable for that page in all the languages of my website so I don’t have to modify each time. Let me explain myself:
I use a text variable called img_pos to set the background-position of the image. I wish to call the variable in the default language (in my case ‘ca’) so that in the template I can call it or change it only once.
Is it possible?? GPTs say to use page.translation(‘ca’).header.img_pos but doesn’t work…
P.D. by the way another issue I have is that {{ dump() }} doesn’t nothing so I use vardump to debug…
im really not sure if i understood right but if what you ask is this:
" i want a variable that works only for default language which is ca, how can i do that in template ? "
here is a code to solve that, put these to near top of twig file if you need
{% set defaultLanguage = grav.language.getDefault %}
{% set activeLanguage = grav.language.getActive|defined(defaultLanguage) %}
later you can do this for variables that appiles for only spesific languages
if activeLanguage is ca do this
else do this
endif
No… I didn’t explain myself well it seems… let me try again.
I have a variable named img_pos in a template so I can use it calling {{ page.header.img_pos }}. What I need is to call the variable of a specific translation (default language) so if I’m showing the ‘es’ translation of the same page it calls the ‘ca’ vesion of the variable. Is it possible?
Thank you very mu ch for the effort but no… sorry, but I feel I don’t explain myself well yet…
This is the website… Agenda | Noemí Pasquina
As you can see, there is a picture for each event. This picture is background-image loaded by URL and placed differently so the customer can adjust the exact y position with the next code:
Now, I want to be able to use the variable saved in the default language version of the same page (in my case is ‘ca’) So that I use the same data for all the translations. Can anyone understand me now?