ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Apostrophe Breaking Conditional Statement

April 16, 2012 12:10pm

Subscribe [2]
  • #1 / Apr 16, 2012 12:10pm

    Zac G.

    268 posts

    Hi,

    I’m wondering why this doesn’t work:

    {if custom_field == "John's House"}do something{/if}

    Any suggestions on how to make this work?

    Thanks!

  • #2 / Apr 16, 2012 12:23pm

    glenndavisgroup

    436 posts

    Hi Zac,

    Try the following:

    {if "{custom_field}" == "John's House"}do something{/if}

    Mike

  • #3 / Apr 17, 2012 8:56am

    Zac G.

    268 posts

    Nope, that didn’t work.

  • #4 / Apr 17, 2012 11:23am

    Shane Eckert

    7174 posts

    Hi Zac,

    I am sorry to hear you are running into this problem.

    When you say it does not work, what are you seeing? Does the logic fail or do you see errors?

    This form should work:

    {if username == "joe"}  <h1>Hi Joe!</h1>  {/if}

    Please let me know!

    Cheers,

  • #5 / Apr 17, 2012 3:01pm

    Zac G.

    268 posts

    Hi,

    Yes, the logic fails.  If I code this:

    {if custom_field == "Joe's"} Something{/if}

    The the conditional statement fails.

    Of course, this works fine:

    {if username == "joe"}  <h1>Hi Joe!</h1>  {/if}

    But it isn’t using an apostrophe.

     

  • #6 / Apr 17, 2012 3:06pm

    glenndavisgroup

    436 posts

    Hi Zac,

    What version of EE are you using?

    Mike

  • #7 / Apr 17, 2012 3:10pm

    Zac G.

    268 posts

    They’re running 2.3.1

  • #8 / Apr 19, 2012 12:49pm

    Shane Eckert

    7174 posts

    Hi Zac,

    I tried this in 2.4 and I get the same results.

    Inside a channels entry loop ...

    {if title == "shane's"} 1 {/if} 

    {if {title} == “shane’s”} 2 {/if} 

    {if "{title}” == “shane’s”} 3 {/if} 

    {if '{title}’ == “shane’s”} 4 {/if} 

    The first fails, the others give me parse errors. (expected the parse errors)

    This sir, is a bug. And now it’s an officially filed bug.

    To stay up to date on the progress of the bug, please leave a comment.

    Thanks for catching and reporting this Zac.

    If you need anything else, please just let us know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases