Hide a button if Content Manager data is empty

Hello, I’m 95% done building a new site. I hit a wall when trying to not show a button on a Dynamic page. I’m currently advertising some events using the courses preset, some events that have more than one time for that day, each time has a Booking Button. The events that have less times for the day I would like to hide the ‘Book Now’ buttons from the screen as these have no reference content in the Content Manager but are still linked to empty connected data fields. I have no experience with Velo, but I see this as the only option to achieve what I need. Any help would be appreciated. Thanks

All you have to do is…

let currentItem = $w("#myDataset").getCurrentItem(); console.log(currentItem);

You will get some results… like…

/*  
 *  {
 *    "_id":                "fcec780a-3e37-4b64-8a66-37c552c53f99",
 *    "_owner":             "f6c0f9c3-a62d-7e9f-g58d-943829af244d9",
 *    "_createdDate":       "2017-05-01T17:19:03.823Z",
 *    "_updatedDate":       "2017-05-01T17:19:10.477Z",
 *    "title":              "Dr. ",
 *    "name":               "B",
 *    "link-dynamic-name":  "/myCollection/B"
 *  }
 */

Than you generate your if-else-query (statement)…

if( ... ) { ... }
else { ... }

Example for —> “title” - DB-FIELD…

if(currentItem.title) {console.log("Title exists on the current selected item.");}
else {console.log("Title do not exist on the current selected item.");}

Put everything withing the onReady-part(s) of your code…

$w.onReady(()=>{ ... });

Including → “datasetOnReady()”-part…

$w("#myDataset").onReady(()=> { ... });

Which would look like…

$w.onReady(()=>{
    $w("#myDataset").onReady(()=> { ... });
});

Awesome thanks! I have another couple of questions on Events if okay? Is it possible to add a field in the event setup for an external URL that is used instead of the standard register form? There’s also a prompt on the event page that states, ‘Select Another Date’ if an event have more than one date, however, I have more than one time on the same day so this is misleading, could it be changed to read ‘Select Another Time’? I will probably reach out personally to help implement this and/or the above.

If you need a developer, of course you can contact me.

Other options for you would be…

You may ask questions, but therefore please open new post with an as most as possible good description of your problem, if it handles another situation/issue. Every issue → should have it’s own post/thread.