Test for existence of gallery in repeater

I have a number of events in a collection. Some of them have a gallery of photos from the event. Obviously I don’t want to show a link to a gallery that doesn’t exist.

My workaround is to add a Boolean field to the collection for “Show Gallery” and then show or hide based on its value, like this:

// Hide inactive buttons in repeater
$w . onReady ( function () {
$w ( “#dynamicDataset” ). onReady (() => {
$w ( “#listRepeater” ). onItemReady (( $item , itemData , index ) => {
if (! $item ( ‘#showgallerybutton’ ). text ) { $item ( “#photobutton” ). hide ();}
}
)
})
});

Is there a better implementation?