I have a page where I want to display either a featured image or an image gallery in the left corner of a text block, which wraps around the image. Pretty basic.

If I use just a single image for the story, I have a class that shows a border around the image. If I decide to use a gallery (via a grid field), the images rotate, and the user can click on them to view larger versions. Also pretty simple.

The complication is evaluating whether either of the two is empty, and if so, show the one that has content. Further, if neither the gallery or single image have any content, show nothing.

I attached my code in Image1 You can also view an example here of the gallery, and HERE of what a single image is supposed to look like (second link is not coded, only "About" template is). The main "About" link is where I have a single image uploaded, but does not show.

Thank you all for any help you can give!!

Gallery and Single Image code with conditionals

1 Answer 1


Have you tried to check for the total_rows variable?

{if gallery_section:total_rows > 0}
{if:elseif about_image_single}
  • Thank you for your reply! I had no idea that was an option. I'll try it as soon as I get back home.
    – Christian
    Jan 25, 2015 at 17:48
  • I just tried your suggestion, and now the grid doesn't output anything. It's as if there are no entries in the grid field, even though there are. See Gallery page, but it returns the single image fine, HERE
    – Christian
    Jan 26, 2015 at 0:31
  • Please, try >= 1
    – Sobral
    Jan 26, 2015 at 1:59
  • Still nothing. I do have content in the gallery, and NO content in the single image, but the code is parsing as if there is nothing there at all... I just don't understand why. I just commented out the If statements and single image just to make sure the gallery still works, and it does. Just not with the conditionals. The single image works though.
    – Christian
    Jan 26, 2015 at 2:15
  • 1
    Strange, strange... Please, take a look at this, this and this.
    – Sobral
    Jan 26, 2015 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.