Open Site Navigation

Hide Empty CMS Fields in Wix

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?


Here is 4.5 minute video describing exactly how to fix this issue:



In this video we used some code. Here is that code so you can copy and paste it into your website!

 

$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.



Now that you have all the code and tools to hide empty CMS fields in Wix, it is time for you to apply this trick to your website! Have fun!


Want to learn more about Wix?

Lean Wix in 1 Hour!


#wix #velo #CMS