Ad

OctoberCMS, Comparing A Record String To A String

- 1 answer

I'm attempting to clean up my Titles in my October CMS Project and I'm running into an issue.

I have a set of pages set to be "Singles" and thus have the title [category]-single which is not great.

So to that end I'm trying to use the [x] in [y] function in twig for an if function as follows;

{% else if ('single' in this.page.baseFileName) %}
<title>[formatted title]</title>
{% else %}

this doesn't help and throws an "Unexpected token "name" of value "if" ("end of statement block" expected)." exception.

No variation I can think of (bracketing out the record pointer, for example) and I'm reaching an impasse on this.

Any help?

Ad

Answer

it seems you are adding extraspace to else if just remove it and use elseif

{% elseif ('single' in this.page.baseFileName) %}
{#  ^ use like this #}
<title>[formatted title]</title>
{% else %}

docs : https://twig.symfony.com/doc/2.x/tags/if.html

if any doubt please comment.

Ad
source: stackoverflow.com
Ad