Hiding Multiple Videos on Dynamic Pages

Hey community!

Just recently got into Dynamic Pages, but I’ve hit a wall.

I have a normal page with a Pro Gallery which works as links to a dynamic page with different clients we have worked with. When you click the image with one of the clients, you are taken to a dynamic page with a gallery and some text as well as a link. All this works perfectly for my use!

Now, I want to add either one or more videos to SOME of the dynamic pages.

I’ve seen that you can use the code underneath to ‘collapse’ the Video Player if there is no video present. This would work if it wasn’t for the fact that fore some clients I want to display 1 video, but for others more or even none. The code for 1 video is as follows:

Original post - It seems like the author of this post is wondering about the same in his latest reply on this post.

$w.onReady(() => {
     $w("#myDataset").onReady(() => {
       // Gets the current item properties and stores them in a variable called item
         const item = $w("#myDataset").getCurrentItem();
           // Checks if the current item has a value in the "video" field  if (!item.video) {
             // Collapses the video player if there is no value for "video"             $w("#videoPlayer").collapse();
      }
  });
});

What I need is a code that collapses multiple videos if there is only one present, or none. I bet it would be easy to just add (“videoPlayer2”) etc. to the code, but I don’t even know how to add that.

The Video Players works fine, and the video is connected properly - Now I just need to hide them when there is no video to show on the given client :slight_smile:

Would love some help from the pros!


BONUS QUESTION:

It seems like the text “VIDEOGRAPHY” show up on all pages, although I have only added the connected text field to the items containing video. Seems wierd… Shouldn’t it just be blank on the live site, if the field in the database is left blank?

Thank you guys so much!

1 Like