1

I'm getting an error if my relationship field does not have any related entries selected:

You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.

Parser State: Invalid Condition: Not enough operands for operator ” > “.

The code throwing the error:

{if {select_testimonials:count} > 0} <--conditional open

      {select_testimonials} <--relationship field open

        {select_testimonials:testimonial} <--relationship:matrix field open

            <div class="testimonial">...stuff...</div>

        {/select_testimonials:testimonial} <--relationship:matrix field close

      {/select_testimonials} <--relationship field close

{/if} <--conditional close

What I'm trying to do here is only show this if there are related entries selected (I don't want an empty div if not).

If the relationship filed does have entries selected, everything works as expected.

What would be causing this error?

I have also tried removing everything but the conditional, and I still get the error, like this:

{if {select_testimonials:count} > 0} <--conditional open

{/if} <--conditional close

1 Answer 1

1

Since the version 2.9 of eecms, the expected format for conditionals is {if var:count > 0}. Some addons make necessary to use {if "{var:count}" > 0}, but just because of the way the developer coded the addon.

As the conditional is related to a 1st party module, probably the first option will work fine. Please, try:

{if select_testimonials:count > 0}
    [...]
{/if}
2
  • Thank you, I tried that and I do still get an error: "You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}. Parser State: Unexpected ‘count’ (VARIABLE); expected RD in.." - the last part (Parser State) is different than the prior... Jan 29, 2015 at 16:42
  • Oh, the second option did work, if I add the quotes, no more errors: {if "{select_testimonials:count}" > 0} - works. Thank you! Jan 29, 2015 at 16:51

Your Answer

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

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