Restricting a gallery to a single collection ( and more)

Hi LM, good point.

I have set up a test page which has a repeater connected to the All Products collection. This displays the unfiltered data correctly.

Having studied some of the links (in the other post you kindly referenced) I have added the following code;

export function dataset1_ready (){
filterCollections ();
}

export function filterCollections () {
$w ( “#dataset1” ). setFilter ( wixData . filter ()
. hasSome ( “collections” , “No stock” )
)
}

The ‘No stock’ collection has one product, so I was hoping that this would display just one product, but it displays nothing.

I’m using the .hasSome function as the collections field in the product table is an array value.

It doesn’t (now) throe any errors but equally does not filter correctly. Any thoughts?

I’ve also taken some code extracts from another of the links which can change some of the repeater elements. I don’t use these but copied them for reference. What code/test would I need to add to this to exclude dataset entries that do not have an image loaded?

Here’s my reference code (commented out)

//export function makeRepeater() {
// $w(“#repeater1”).forEachItem( ($item, itemData, index) => {
// if (itemData.description.length > 100) {
// $item(“#description”).text = itemData.description.substr(0,100) + “…”;
// }
//
// //if (itemData.price <10) {
// // $itemData(“addToCart”).label = “Cheap Product”;
// //}
// });
//}

Appreciate any help you can give.

Rgds, Ratty