twig - 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?
解决方案
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.
推荐阅读
- parameters - 替换修饰符中的参数扩展
- php - 从两个 mysql 表中获取数据并用 php 显示显示顺序不正确
- elasticsearch - 从 Xpath 创建嵌套字段并检查现有文档
- django - ORM Django 和 DB postgreSQL 用于 B-tree 索引的方式是什么?
- javascript - React.js TypeError:解构不可迭代实例的无效尝试
- buildroot - avahi 只工作几分钟
- machine-learning - 如何通过过去的数据预测未来的数据?
- html - 浏览器更改大小时阻止图像重叠
- python - Pandas 使用 JSON 模板映射(重新排序/重命名)列
- php - 使用 laravel/passport 时密文太短