ExpressioneEngine contains operator doesn't work

191 views Asked by At

I'm trying to have expressionengine check a channel field for a word and if that word is found, it will display the contents of another field.

In this case, I want it to search {links-title} for the word "Volunteer" and if the word "Volunteer" is found, it will display the contents of {links-branch}.

Here is the code I'm trying to use:

{exp:channel:entries channel="locations-links"}
{if links-title *= "Volunteer"}
{links-branch}
{/if}
{/exp:channel:entries}

This page: https://ellislab.com/expressionengine/user-guide/templates/conditionals.html#contains-operator says the contains operator is *= but when I use it, the page displays completely blank. It literally seems as though this operator just does not work. If I use == it works, but in that case, {links-title} has to be "Volunteer" exactly and nothing else.

Anyone know how what is going on here?

2

There are 2 answers

0
Jelle Dijkstra On

Your question should be asked over at expressionengine.stackexchange.com actually. anyway, what version of EE are you using? The handling of conditionals changed a lot in more recent versions, and you are using the docs from the latest version of EE. If your site is not running EE 2.10 you better consult the docs for the version you are using

0
Chego On

Sometimes you have to put curly braces around the variable name. Try this:

{exp:channel:entries channel="locations-links"}
{if "{links-title}" *= "Volunteer"}
{links-branch}
{/if}
{/exp:channel:entries}