I'm using a simple grid conditional to show academic references in a post. I only want to show it if someone has entered some references, but the conditional just isn't working. What am I doing wrong?

My code is:

{if references:total_rows > 0}
    <h5>Further Reading</h5>
    <li>{references:names}, {references:pub-year}, {references:title-work}, {references:publisher}, {references:country} </li>

I've also tried using " and brackets to surround the if condition but that doesn't work either.

3 Answers 3


This is a known bug in EE 2.9. If you're using modifiers in conditionals, use the (otherwise not recommended) quoted-braced syntax instead:

{if "{references:total}" > 0} ... {/if}
  • thx, I did try this previously as had seen the issue elsewhere on here... it didnt work. Ill try it again to make sure
    – Boshy
    Jan 7, 2015 at 10:25
  • UPDATE: Yes this appears to be the only way I can get the refs to show up if they are there, they will not show without the 'quoted-braced' code. When I tried doing this before I must've done it the wrong way round (brace/quote not quote/brace). My other stupid mistake was setting the field grid minimum row to 1, and presuming that if it was empty it wouldn't show up - of course it does as activates any text that might present in the conditional code even though the row is empty - silly mistake.
    – Boshy
    Jan 8, 2015 at 12:55

Should that conditional even be needed? The tag pair shouldn't return anything if there isn't at least one row, so could you not simply do something like this:

{if references:count == "1"}<h5>Further Reading</h5><ul>{/if}
<li>{references:names}, {references:pub-year}, {references:title-work}, {references:publisher}, {references:country} </li>
{if references:count == references:total_rows}</ul>{/if}
  • That has always left a space/gap when nothing exists when I have tried. ;)
    – W3bGuy
    Jan 7, 2015 at 0:12
  • Ot shouldn't leave a thing in the template at all with the way I have it set up here - the h5 and opening ul only get inserted if there are entries, and likewise the closing </ul> only gets inserted after the last entry (which doesn't exist if there are no entries). And everything in between would also only be inserted for each entry found, which if zero, would result in no output at all between the tag pair, just like an entries loop. Jan 12, 2015 at 15:37
  • I agree that it shouldn't, but it has in previous installations for me. I have had to perform various workarounds. It may just be due to some of the "buggy" releases that have been let out by Ellis in the past. ;)
    – W3bGuy
    Jan 12, 2015 at 17:35

I am using this code in EE2.9 without the quotes and am having zero issues. The issue @Low is referring to is when you are comparing the variable as a string. AFAIK

{if service_page_copy:total_rows > 0}
        {if "{service_page_copy:headline}" != ""}
        {if "{service_page_copy:copy}" != ""}

I have run into a couple of oddities in the past. The only thing I can think of that you may want to try is this:

  1. Try changing the name of your field to make sure it isn't a reserved or conflicting name.
  2. Try changing your names from '-' hyphens to '_' underscores to see if that resolves your issues.

If not, let me know and I can try to replicate it on a local test environment. :)

  • ok Ill try this and let you know...
    – Boshy
    Jan 7, 2015 at 10: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.