Hide a specific database item in a repeater

Hi!

I’m trying to hide a database item that is part of a repeater.
Simply put, I have a “latest content” list on each item page, and I would like the item part of this “latest content” list to be hidden if the user is currently browsing this item page. Each item has a unique ID, so that’s the data I’d use to make that work.

Basically : if (item in latest content list) === (same content the user is browsing the page of) then hide this item in the “latest content list”

Here’s a screenshot so you can see what I’m talking about.


https://www.wehaveadeal.net/deals/1574971366

Any idea how to pull this off? Thanks!

Hi,
if I understand you correctly, you are using a repeater to display recent deals. You can use forItems repeater function to hide the specific item from the repeater (the first one, which is the same as the current page). Click here to learn more.

Thanks, do you have an example of what code to write ?

@tristan-breon-1 I don’t have an example code for this specific functionality, however you can see general examples in the API reference.
I have also checked your site and I see that you have updated it and it no longer shows the current item in the recent deals. It would be great if you can share your solution here for people who might face a similar issue.

@aleksf That’s because I added other deals in the meantime.
So basically what I could do is check if there’s an item that has the same unique ID as the one being browsed, and if yes, hide it. Any idea how to code it?

I have this so far :

$w("#dataset1").onReady( () => {
$w("#repeater4").forEachItem( ($w, itemData, index) => {
    //sets the price in green if the text is GRATUIT
    if ($w("#text83").text === "GRATUIT") $w("#text83").html = `<span         style="font-family:arial; font-weight: bold; color:#16B326; font-size:14px">${$w("#text83").text}</span>`;
});
});

but no idea how to query the unique ID that belongs to each item, to compare it with the item that is being browsed.

@tristan-breon-1 Since you’re using a dataset, you don’t need a query. Just add a filter to your dataset through the GUI so that _id is not dynamic page _id .

@skmedia Alright, but I don’t understand the rest of your comment. What’s GUI? and what do you mean _id is not dynamic _id ?

@tristan-breon-1 graphical user interface AKA not through code, just through the editor. You’ll see at the bottom of your dataset’s settings in the filter category what I mean.