Show slideshow filtered by 'is empty' field key to remove that slide

Hi I have a number of slides that i’d like to be shown only if the content in those slides is linked to a field key which is not empty. Is this possible?
Thanks
Adam

Have you looked at the isNotEmpty function in Wix Data Query?
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#isNotEmpty

Thanks @givemeawhisky , it’s a very good API i’m just wondering how I can code this in relation to a slide in a slideshow to omit a slide if a field key is empty .

for example slide 2 has a text element that is attached to field key, nickName. If the user hasn’t added a nickname then without any filtering this slide will appear blank but should really be hidden or omitted if possible, is this possible with wix query and slideshow api?

What should this code look like to conduct a query and omit slide 2 if the field key is actually empty?

Hi Jon @jonatandor35 can you see a solution for having a slide that may or may not be populated by user input, in this example a text element linked to ‘nickName’ field key so coding omit that slide if the field key is empty ?

can i achieve this with code?

@adcatch02 , your questions are not clear enough. Really you should put more effort in phrasing them.
Take into account that no one knows your system and your site, and we just can’t guess the exact flow and scenarios.
Please add all the necessary details & screenshots etc. And try to think what the reader will understand from the description.

@jonatandor35 J.D. please see a better attempt at explaining my question and help required. I hope this helps explain and visualise what i’m asking for

@adcatch02 and what? Does the user have to input his/her name in this page? Does it pull the user details only if they’ve been submitted before?
Let’s say that the 2nd option is what you mean, then you’ll need to set the slide switch by code only (to remove the arrows), and skip the slides that are not relevant to this user.
Something like:

//...code...code
let currentNumber = 0;
let slideIndices = [0, 1, 2, 3, 4, 5];
if (!currentItem.name){
    slideIndices = [0, 2, 4, 5];
}
$w("#previosButton, #nextButton").onClick(event => {
    event.target.id === "nextButton" ? currentNumber++ : currentNumber--;
    $w("#sildeshow1").changeSlide(slideIndices[currentNumber]);
})

@jonatandor35 thanks. yes the data has already been populated in the collection so my slides are pulling various field key entries on each slide. I’ll give this a go.Thanks

@adcatch02 and of course wrap it in $w.onReady() and dataset.onReady() as usual.

  • add getCurrentItm() as usual

I’m not sure if this was the intent from yourself or if i have messed up the code but the only thing that this code does at the moment is show a previous button and next button on slide 3 with the existing navigation buttons, all the slides are displayed?

I’m trying to figure out how i can use this to determine in advance of running the slideshow on the page if it actually contains a ‘nickName’ field key and if it does runs normally and if it doesn’t uses this code - assuming that I can skip slide 2

or i thought that adding nickName as follows might work

  1. Make sure you put Next and Previous buttons in your page.
  2. Change the slideIndices in line 9 to the slides indices you want to show no matter what.
  3. make sure the field in you DB is nickName and not nickname.
  4. Get rid of the native navigation arrows (via the editor - slideshow settings).

@jonatandor35 do i need to add my own navigation links for every slide?

if i need to add more buttons on line 12 do i add like this?
$w(“#previousButton, #nextButton” + “#previous1, #next”).onClick(event => {

@adcatch02 It’s easier to put the navigation button outside the slide, otherwise you’ll need to modify the code.
If you want these navigation buttons to be over the slideshow, take 2 transparent boxes, make them a little bit bigger ( in height ) than the slideshow height (so it won’t be a child of the slideshow), put each of the on the other side of the screen (over the slideshow), and put the navigation buttons (which you can design as an arrow) inside the box. (I hope this explanation is clear enough. Let me know if not).

@jonatandor35 Thanks J.D. that works. I do get this error code though and when i get to the last Slide there is no loop back to the first slide. Can this be achieved ?

  1. Wix code SDK error: The slideInfo parameter is required for changeSlide method.

@adcatch02 What would you like to get? The first slide again or to disable the Fw button?

@jonatandor35 ideally loop back / through to the first slide please

@adcatch02 so between lines 13-14 (in your last screenshot numbering), add:

currentNumber %= slideIndices.length;

(But of course you should also think of what you’d like to happen, if the user clicks “previous” on slide zero).

@jonatandor35 very good point. It would be a good idea to hide slide 0’s previous navigation only on Slide 0. Can i specifically add the code for that please or just let the user go back through previous slides like the code above but for previous

@adcatch02 so make this button hidden on load, and after the currentNumber %= slideIndices.length; add:

currentNumber === 0 ? $w("#perviousButton").hide() : $w("#perviousButton").show();

@jonatandor35 That’s great Jon, thank you.

Can I ask so that i can be clear, that this code does in respect of getCurrentItem.nickName on line 5 and ifCurrentItem.nickName on line 8

Gets the current item properties and stores them in a variable called item
//const item = $w(“#dataset1”).getCurrentItem().nickName;
// Checks if the current item has a value in the “nickName” field

then

//if (!item.nickName) {
// Skips the slide with nickName if there is no value for “nickName”

but if there is a value for “nickName” would show that slide?