With the caveat that I’m a Velo beginner, here’s code that I am using to expand a section based on a condition. Maybe it will help.
photoSection1 is a section on the page that is set to ‘collapsed’. It contains an image element connected to the collection field image1 .
image1 is a field in the collection that may or may not contain an image.
This code uses the page’s dataset to get the current collection item and checks whether there is content in the field image1 . If that field contains an image, the section in which it’s displayed ( photoSection1 ) will be expanded. If not, it remains collapsed.
It might be clearer if I had a separate boolean field (e.g. image1Exists ), but the presence / absence of the image is interpreted correctly as a boolean.
$w . onReady ( function () {
$w ( ‘#dynamicDataset’ ). onReady (()=>{
**if** ( $w ( '#dynamicDataset' ). getCurrentItem (). image1 ) {
$w ( “#photoSection1” ). expand () } ;
// a lot of additional code you don’t need
})
})