Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
2673 Visualizzazioni

Hi folks,

We're working with odoo 8.1 and one task is to build a website, which is nearly done.


The problem: our website is bilingual  and we have a banner slider - is it possible to change the images of the banner slider as soon as the user clicks on the language-toggle?


How much effort does this take - to me a possible solutions might be a JavaScript DOM manipulation.  Am I right?

Thanks in advance!

Avatar
Abbandona

Thanks Ermin Trevisan! One question: Will this module work with odoo V. 8.1?

There is no such thing as Odoo 8.1. It is working for your Odoo version.

Risposta migliore

You can also drop 2 sliders, and add with the html editor a t-if lang='lang1' and t-if lang='lang2' to choose which one is shown to the end user.

 

Avatar
Abbandona
Risposta migliore

You can do this by adding javascript by adding a <code> block where you want to add a multilangual change.

<!-- your HTML image -->
<img id="taal-img" src="https://your.website.url/image.png" alt="alt text" style="width:100%;" loading="lazy">

<script>
  (function() {
    const path = window.location.pathname;
    const img = document.getElementById("taal-img");

    if (!img) return; // If image does not exist, stop
//
    if (path.startsWith("/en/")) {
      img.src = "https://your.website.url/image_en.png";
    } else if (path.startsWith("/fr_FR/")) {
      img.src = "https://your.website.url/image_fr.png";
    } else {
      img.src = "https://your.website.url/image.png";
    }
  })();
</script>

path.startsWith is the place where you set your language.
You can see this value when you go to your website and change to another language.

If there is no value the standard image will be shown (standard language of website)

Hope this helps

Avatar
Abbandona