Hide lightbox pop-up depending on language?

Dear forum.

I’ve recently launched the English version of my website. On my native (Danish) version, I have a pop-up that prompts the user to sign up for my newsletter after 8 seconds on the site - but since I do not have an English newsletter yet, I’d like to NOT show the pop-up if the selected language is English.

I’ve looked at this thread: Hide Lightbox from multilingual site - #4 by ahmadnasriya

…but it’s not working for me. I suspect it might be because I’m already calling some other functions (to filter database-content based on language), and I might not be putting it all together correctly…

On top of that I also have the same question as was posted in the above mentioned thread: if I want to wait a number of seconds before loading the pop-up, how do I do that? And how do I make sure the database content is loaded BEFORE the “x second” wait for the pop-up starts?

The code I use is:

import wixWindow from ‘wix-window’;
import wixData from ‘wix-data’;

// …

$w.onReady( function () {
let language = wixWindow.multilingual.currentLanguage;
$w(“#dataset1”).setFilter( wixData.filter().eq(“language”, language) );
> if (language === ‘da’) {
> wixWindow.openLightbox(‘#lightbox1’);
}
);

export function repeater5_itemReady($item) {
let language = wixWindow.multilingual.currentLanguage;
$w(“#dataset1”).setFilter( wixData.filter().eq(“language”, language) );
}

Thanks in advance!

Hi,

I noticed that there might be a minor issue with the way you are opening the lightbox.

According to the openLightBox() documentation:

Notes: Use the name of the lightbox and not the lightbox’s ID when calling openLightbox() . You can find the lightbox’s name by selecting the lightbox and clicking the settings button.

This means instead of:

wixWindow.openLightbox(‘#lightbox1’);

You should use the Lightbox name:

wixWindow.openLightbox(‘Lightbox 1’); //Use the Lightbox Name

Hi Thomas.

Thank you so much for correcting this! I had a look at the documentation and noted two other things: 1) The Lightbox Name has " around it, not ’ - and 2) The very first line of the code says " import wixWindowFrontend from ‘wix-window-frontend’;" which I did not have in my code before.

So, now my code is this:

import wixWindow from ‘wix-window’;
import wixData from ‘wix-data’;
import wixWindowFrontend from ‘wix-window-frontend’;

// …

$w.onReady(function () {
$w(“#dataset1”).setFilter(wixData.filter().eq(“language”, language));
if (language === ‘da’) {
wixWindowFrontend.openLightbox(“Tilmeld nyhedsbrev”);
}
};

However, unfortunately it still does not work. Any ideas as to where I’m wrong?

best, Lars