# How to hide a section on a dynamic item page when a specific CMS field is blank

**URL:** <https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241>\
**Category:** Ask the community\
**Tags:** wix-studio, cms, code\
**Created:** [June 24, 2024, 12:57pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241 "2024-06-24T12:57:03Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Teri\_Sutherland](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/teri_sutherland/32/87258_2.png) [@Teri\_Sutherland](https://forum.wixstudio.com/u/Teri_Sutherland)\
**Post date:** [June 24, 2024, 12:57pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/1 "2024-06-24T12:57:03Z")

</div>

How can I hide a particular section on a dynamic item page when a specific CMS field is blank?

Working in Wix Studio Editor

I have a dynamic item page set up for football player profiles. I have a section that I want to show the “Awards” , which are linked to a field in a CMS. However only some players have awards listed in the CMS. So I’d like to hide this section when that CMS field is blank for a particular player.

This is the code I’ve tried, but it is incorrect.

$w(“#playerStats”).onReady( () =\> {

```
    if (awardsReceived) {
        $w("#section64").hide();
    } else {
        $w("#section64").show();
    }
});

```

});

I’d be grateful for any assistance.

---

<div class="post-metadata">

**Author:** ![Koen\_Stewart](https://avatars.discourse-cdn.com/v4/letter/k/57b2e6/32.png) [@Koen\_Stewart](https://forum.wixstudio.com/u/Koen_Stewart)\
**Post date:** [June 24, 2024, 4:10pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/2 "2024-06-24T16:10:01Z")

</div>

Hey, I’m happy to help! Could you send me a screenshot of the code panel with the page.

---

<div class="post-metadata">

**Author:** ![Dan\_Suhr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dan_suhr/32/94074_2.png) [@Dan\_Suhr](https://forum.wixstudio.com/u/Dan_Suhr)\
**Post date:** [June 24, 2024, 8:57pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/3 "2024-06-24T20:57:40Z")

</div>

This code works

```javascript
$w.onReady(function () {

$w("#dynamicDataset").onReady( () => { 
       let item = $w("#dynamicDataset").getCurrentItem(); 

       if (item.onlineBookingLink) { //change to field key
          $w("#button1").show();
       } else {
          $w("#button1").collapse();
          $w("#button1").hide();
       }

```

---

<div class="post-metadata">

**Author:** ![Teri\_Sutherland](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/teri_sutherland/32/87258_2.png) [@Teri\_Sutherland](https://forum.wixstudio.com/u/Teri_Sutherland)\
**Post date:** [June 24, 2024, 9:57pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/4 "2024-06-24T21:57:24Z")

</div>

Hey Koen, that’d be fantastic thank you.  
Here’s a screenshot of the page. The code in my question is all that’s currently in the code panel. The section I’m trying to hide when the CMS field is empty, is the section where the field is on if that makes sense. It’s the “awards received” container (which is on it’s own section.)

 ![Screenshot 2024-06-25 at 7.51.16 AM](https://us1.discourse-cdn.com/wix/original/3X/0/3/03a9f97f5a982a7689b3277d260a14f8e423b670.jpeg)

---

<div class="post-metadata">

**Author:** ![Teri\_Sutherland](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/teri_sutherland/32/87258_2.png) [@Teri\_Sutherland](https://forum.wixstudio.com/u/Teri_Sutherland)\
**Post date:** [June 24, 2024, 9:58pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/5 "2024-06-24T21:58:02Z")

</div>

Hi Dan, this doesn’t seem to work unfortunately.

---

<div class="post-metadata">

**Author:** ![Dan\_Suhr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dan_suhr/32/94074_2.png) [@Dan\_Suhr](https://forum.wixstudio.com/u/Dan_Suhr)\
**Post date:** [June 24, 2024, 10:24pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/6 "2024-06-24T22:24:50Z")

</div>

show me the code you used - I have this working on a site with no problems.

ps… go QLD

---

<div class="post-metadata">

**Author:** ![Teri\_Sutherland](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/teri_sutherland/32/87258_2.png) [@Teri\_Sutherland](https://forum.wixstudio.com/u/Teri_Sutherland)\
**Post date:** [June 24, 2024, 10:36pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/7 "2024-06-24T22:36:05Z")

</div>

Thanks Dan – Yes, it’s entirely possible I’ve put this in incorrectly. Here’s a screenshot:

 ![Screenshot 2024-06-25 at 8.35.07 AM](https://us1.discourse-cdn.com/wix/original/3X/9/f/9f1983de793a6dc086d3a221186d504dc9b3cff5.png)

---

<div class="post-metadata">

**Author:** ![Dan\_Suhr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dan_suhr/32/94074_2.png) [@Dan\_Suhr](https://forum.wixstudio.com/u/Dan_Suhr)\
**Post date:** [June 24, 2024, 10:44pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/8 "2024-06-24T22:44:28Z")

</div>

so you have an error with the dataset name #PlayerStats. Check you have the correct name and see if that fixes the issue. I have not tested this code with a whole section, just individual elements.

if you are still having issues let me know and I can help fix.

---

<div class="post-metadata">

**Author:** ![Teri\_Sutherland](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/teri_sutherland/32/87258_2.png) [@Teri\_Sutherland](https://forum.wixstudio.com/u/Teri_Sutherland)\
**Post date:** [June 24, 2024, 10:47pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/9 "2024-06-24T22:47:05Z")

</div>

Hmm. it says it’s that name when I go to the settings…  
 ![Screenshot 2024-06-25 at 8.46.12 AM](https://us1.discourse-cdn.com/wix/original/3X/9/c/9c704fbc533b5f55511511d6a8379ebc96a7aebf.png)

---

<div class="post-metadata">

**Author:** ![Teri\_Sutherland](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/teri_sutherland/32/87258_2.png) [@Teri\_Sutherland](https://forum.wixstudio.com/u/Teri_Sutherland)\
**Post date:** [June 24, 2024, 10:55pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/10 "2024-06-24T22:55:09Z")

</div>

Ok just realised that’s the collection ID not the dataset name. Changed it, but it still doesn’t work. Yes, I’d love some help to fix please.

---

<div class="post-metadata">

**Author:** ![Koen\_Stewart](https://avatars.discourse-cdn.com/v4/letter/k/57b2e6/32.png) [@Koen\_Stewart](https://forum.wixstudio.com/u/Koen_Stewart)\
**Post date:** [June 24, 2024, 10:57pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/11 "2024-06-24T22:57:54Z")

</div>

Would you be willing to get on a quick 5m virtual call so that i can help you out with this?

---

<div class="post-metadata">

**Author:** ![Dan\_Suhr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dan_suhr/32/94074_2.png) [@Dan\_Suhr](https://forum.wixstudio.com/u/Dan_Suhr)\
**Post date:** [June 24, 2024, 11:00pm UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/12 "2024-06-24T23:00:49Z")

</div>

@Teri_Sutherland - I have messaged you.

---

<div class="post-metadata">

**Author:** ![stevemondaymedia](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/stevemondaymedia/32/80631_2.png) [@stevemondaymedia](https://forum.wixstudio.com/u/stevemondaymedia)\
**Post date:** [June 25, 2024, 4:40am UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/13 "2024-06-25T04:40:11Z")

</div>

I use the below example all the time.  
Note the exclamation mark before currentItem, this means ‘if empty’.

Replace:  
#yourDatasetID with the ID of your dynamic page dataset  
databaseFeildID with the field ID in the CMS you want to check  
#itemToHideID with ID of the page item you wish to hide

```javascript
const currentItem = $w('#yourDatasetID').getCurrentItem();

$w.onReady(function () {
     if (!currentItem.databaseFeildID) { $w("#itemToHideID").collapse(); }
});

```

---

<div class="post-metadata">

**Author:** ![Teri\_Sutherland](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/teri_sutherland/32/87258_2.png) [@Teri\_Sutherland](https://forum.wixstudio.com/u/Teri_Sutherland)\
**Post date:** [June 25, 2024, 5:06am UTC](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/14 "2024-06-25T05:06:49Z")

</div>

Boom! That did it! Thanks so much for your help!
