top of page
atlan logo green.png

Start a project

Start a project

Selected work
​

Practical guides on Wix Studio, Velo, Squarespace, e-commerce and SEO — written from real client projects.

​

​
Share Post

Keep reading

Journal

Hide Empty CMS Fields in Wix

Writer: Atlan Design
Atlan Design
Dec 15, 2020
1 min read

Updated: Sep 19

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?

Wix dynamic page hiding empty CMS fields with Velo

$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