top of page
Lanre Olayiwola

Lanre Olayiwola

Hide Empty CMS Fields in Wix

Updated: Dec 29, 2023

Have you ever created dynamic pages using a database and find out that some information on some pages just wasn't necessary? For example, when creating dynamic pages for team members, maybe some do not have LinkedIn pages to link to. Then it would be a little awkward to include an empty LinkedIn link on their profile page, right?

CMS Fields

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

       let item = $w("#myDataset").getCurrentItem(); 
       if (item.image) {
          $w("#imageElement").show();
       } else {
          $w("#imageElement").collapse();
          $w("#imageElement").hide();
       }
    } );

To make sure that the code is fully functional on your website, make sure the name for #myDatabase is the same as the database element on your page. And make sure the name for each #imageElement is the same for what element you want to hide or show on the page.

Comments


bottom of page