2

I am using EE v2.5 and following the documentation from https://docs.expressionengine.com/v2/templates/conditionals.html

I am trying to create an If Statement where if the Channel field labelled 'title' starts with the word 'Weld', it outputs something.

The title outputs on it's own as 'Weld Quip'

My code is:

{exp:channel:entries show_expired="yes" show_future_entries="yes" channel="service_agent_distributor" limit="1" url_title="weld-quip-group-pty-ltd"}
{if "{title}" ^= 'weld'} some text {/if}
{/exp:channel:entries}

I have also tried to create statement based on segments like this:

{if segment_2 ^= "weld"} Some text {/if}

I get a blank screen with one error: Parse error: syntax error, unexpected 'FALSE' (T_STRING) in /public_html/clients/projectname/area51/expressionengine/libraries/Functions.php(683) : eval()'d code on line 350

If I remove the 'if' statement it works again. Does anyone know why it wouldn't be working?

I should point out that this works, but I need the 'starts with' conditional to work.

{if segment_2 == "weld"}HELLO WORLD {/if}

1 Answer 1

0

You will not be able to use that operator.

https://docs.expressionengine.com/v2/about/changelog.html#version-2-9-0

This is when that operator was added to ExpressionEngine, nearly two years after the version you are using.

Upgrading is absolutely what you should do, but if you can't (many can't for a variety of reasons), your best bet is to use a plugin, or write a quick one yourself. Search here for EE2 add-ons and maybe one will work for you:

https://devot-ee.com

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.