0

EE 2.9.2, Structure 3.3.17 In running a conditional to compare a page title and it's Structure parent, the conditional returns false if there is "&" or any other punctuation in the string.

{if title == "{structure:top:title}}
   do something
{/if}

Simple enough? This works great if there is no punctuation or other special characters in either. i. e. if the title is "Administration & Finance" the conditional fails. If it is "Administration and Finance", it returns true. Placing & in the title works, but then other Structure tags ( breadcrumbs ) print it out verbose ( I get Administration & Finance ) . Plus I can't expect editors to remember to put code in the title.

Any ideas?

1
  • I'm sure there's a better solution, but for an immediate fix you could use something like Streeng to encode both title and structure:top:title variables and save each as stash variables. Then do the conditional with the stash variables. Or query... Commented Apr 4, 2017 at 14:49

1 Answer 1

1

You appear to be missing a " in your example - putting this back might fix things. If not, Romans-8 idea of using streeng seems viable. Something like:

{if {exp:streeng encode="yes"}title{/exp:streeng} == {exp:streeng encode="yes"}{structure:top:title}{/exp:streeng}}
   do something
{/if}
1
  • I ended up using ce_string and converting them to url_titles for comparison. That was the only thing that worked. I was just wondering if there was a bug/glitch somewhere that was causing the initial comparison to fail, with out a plugin.
    – Jim Wyse
    Commented Apr 6, 2017 at 14:39

Your Answer

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

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