We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Test for empty text field if contains an apostrophe?

How Do I?

SChristy's avatar
SChristy
23 posts
8 years ago
SChristy's avatar SChristy

I am trying to test whether a channel field is empty. I did this successfully on EE2.5 but on EE3.3.3, it gives me an error.

So, for testing purposes, I created a channel with one textarea field named “tester_text”. Here is the template:

{exp:channel:entries channel="tester"}
 
 {if "{tester_text}" != ""}
  {tester_text}
 {/if}
 
{/exp:channel:entries}

If tester_text has text in it without an apostrophe, it works correctly. However, if there is an apostrophe, I receive this error:

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 ‘s’ (VARIABLE); expected RD in Template “amp_site/testy” on line 3.

So, how do I test this type of field? Is this a bug or is there another way to test?

Any help appreciated! Thanks

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
8 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

How about…

{if tester_text}
{tester_text}
{/if}
       
SChristy's avatar
SChristy
23 posts
8 years ago
SChristy's avatar SChristy

Wow! You win with the fastest working response I have ever seen on this board! Thanks! I have been trying to figure this out all day and never thought to test it that way.

Thanks, Steve

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
8 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

For future reference, you do not have to escape fields, example:

{if fastest == "pedro"}gold{/if}
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.