Running up against a problem in the use of an Assets field tag in a conditional where there's single quotes entered into the field (in this case the Caption field).

Caption: Otherwise know as 'Old man's beard'.

Template code:

{if "{mc_media_image:caption}" != ""}



Error message returned:


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 ‘Old’ (VARIABLE); expected RD in Template “_includes/incopy_images” on line 46.

The question is how can I test for the existing of content on a caption field if there's a quote in the field? EE v2.8.1 didn't have the same problem as the conditionals weren't as strict as they are now in EE v2.9

Would appreciate some help on this one thanks.

  • I am also having this issue. Any info?
    – SteveO
    Feb 13 '15 at 15:54

Have you tried it without bracing and quoting? (which has always been recommended against). E.g.:

{if mc_media_image:caption != ""}
  • Sure did, slightly different error, but wasn't the solution. Sep 9 '14 at 22:50
  • Running the latest version of Assets? Sounds like variables not being prepped for conditionals properly. You should't ever have to quote and brace; even when it "works" on < 2.9, you are introducing a potentially site breaking and/or security issue. What's the error message after removing quotes and braces? Sep 10 '14 at 15:51
  • Not an error as such it turns out, it just doesn't match the condition at all when it should be. Sep 10 '14 at 22:48
  • Any resolution to this? I'm in the same exact pot of stew, with a var_prefixed Playa field. I can't do {playa_field var_prefix="related_entry"}{if related_entry:custom_title_field}{related_entry:custom_title_field}{if:else}{related_entry:title}{/if}{/playa_field} because, like Brendan says, it never matches even when the custom_title_field has content, and wrapping it in braces or braces + quotes results in template errors.
    – Sandwich
    Nov 21 '14 at 12:49
  • Sounds like a similar issue, those variables likely aren't being prepped properly. I'd recommend contacting the developer. Nov 21 '14 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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