5

I have a playa field product_videos and am using the following conditional to check if it is empty:

{if product_videos:total_children > 0}
  //do something
{/if}

This seems pretty straight forward to me, what am I missing?

I should add the result is that the code inside the conditional never appears despite there being entries.

I have also tried:

{if "{exp:playa:total_children field='product_videos'}"}
  //do something
{/if}

which is listed as a correct answer in this SO question, this results in a php error:

A PHP Error was encountered Severity: User Warning

Message: Invalid EE Conditional Variable: {if "exp:playa:total_children entry_id="285" field='product_videos' var_prefix="playaDbig9XJo"}

Filename: libraries/Functions.php

Line Number: 2855

1 Answer 1

7

...And as soon as I write it down in a question, I figured out my mistake.

Correct solution for future visitors was:

{if "{product_videos:total_children}" > 0}
  //do something
{/if}
2
  • 2
    I usually wait a couple of minutes before hitting submit. 90% of the time just writing my question gives me the answer. hah Aug 28, 2013 at 13:41
  • @JasonVarga Seems like a good idea, I will try to remember that next time.
    – Thomas
    Aug 28, 2013 at 17:30

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.