首页 > 解决方案 > OctoberCMS, comparing a record string to a string

问题描述

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?

标签: twigoctobercms

解决方案


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.


推荐阅读