I am creating articles for my website using a database and dynamic pages. On my dynamic page I have used some text and images to create different paragraphs:
In some articles there is no image between paragraph1 and paragraph2; in that case there is huge white gap between these paragraphs (because the image-element has no value). I am wondering if it is possible using code to hide this element if their is no image to show.
Just throw in a if statement on your on ready function to check if the image is present. If not use the collapse() method on the image object and it will collapse the white area.
The dynamic page have a dataset so read in the API about the dataset and the method onReady on the dataset. You must put the if within the pages onready and as well within the datasets onready to make sure the dataset and image are loaded before you check.
Same issue on my site - has this info worked for you? I’m trying to follow along to fix my own layout, but this is my first coding experience so I am struggling to understand some of the instructions in the tutorials.
Hi,
This should work. Should the issue persists, please clarify what is the scenario (to make sure that it is the same one as “vanmaaren” ) and send us the site URL so that we can have a look.
I am trying to do the same, but with a video. I am a bit stuck, in one of my datasets that doesn’t have a link to any video, the video still shows up on the page. What am I doing wrong?
#CaseStudies dataset is the name of my dataset #video1 is the element on the dynamic page
Thank you Tal! The address is nawayaegypt.org/hub/casestudies/cases (it’s a dynamic page called Case Studies Cases (title)) – it is not live yet though, do I need to publish it so you can see it?
Actually I’ve fixed the original problem – I was naming the dataset wrong. But not I have the opposite problem. The video and title text “Video” both collapse even when there is a video in the dataset.
This code works for me but only on the first item in the dataset. If I include a “console.log” statement where the show and hide lines are, I can see it is only logging once. Should it work for all returned items or is there different code for this scenario?
Hello Greg and Marina, i used the above code samples and the tutorial link sames. but my image is collapsing on every page now even if the field has an image.
has anyone resolved this with a working code sample?
please help. thank you
Hi Greg. This was a long time ago but did you figure anything out. I am also working with a dataset and find it currentItem seems to be only first item so its like it doesn’t really iterate them… or that event doesn’t fire as it’s iterated onto the page.