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?

  • 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... – Romans-8---31-39 Apr 4 '17 at 14:49
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}
  • 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 Apr 6 '17 at 14:39

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.