Is it possible to use a count conditional (or equivalent conditional) to change the display of an entry tag depending on how many entries there are?

For example, I have a grid field which I am using for a simple image gallery. I would like to add a condition so that if there is only one entry the image will display as a hero banner, but if there is more than one entry it will change to a gallery.

I wasn't sure if the following (or similar) was possible:

{if count > 1}
   <!-- Gallery -->        
   <!-- Hero Image -->          

Thanks for any help.

  • I literally just woke up, but I'm certain you can do what you're asking. If no one picks this up, I'll have an answer for you in a few hours.
    – jrothafer
    Commented Jul 3, 2015 at 11:12

1 Answer 1


Certainly, what you want to do is this :

  {if total_rows < 2}
    {!-- Hero Banner goes here --}
    {!-- Each Gallery Image displayed here --}

Note that for what you're asking (if more than one do X else do Y) on a grid field you will need to use the {total_rows} parameter (or for channel entries its {absolute_results}).

Also, note the parse order. Simple conditionals are parsed before module tags, advanced ones after. I don't think it makes a different but if you're not getting the right results change the {if total_rows < 2}{if:else}{/if} to a {if total_rows < 2}{/if}{if total_rows > 1}{/if}

  • 1
    Bastard! :P I wanted to claim this one :)
    – jrothafer
    Commented Jul 3, 2015 at 12:05
  • ROFL, I so almost put a comment about sniping your awnswer too JChrono ! :P lol, let me find a few of your other answers, a few up votes will soon correct the point difference (PS> I know what your doing, you know I've not been able to get on here much lately, trying to de-throne me on this months points table!) hahahaha
    – Blatant
    Commented Jul 3, 2015 at 16:27

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.