How to get the position of a keyword in a line string or array in the Anqi CMS template?
index
How to use
index
How to use filters:
{{obj|index:关键词}}
For example, judgment欢迎使用安企CMS(AnQiCMS)
Calculation inCMS
The location where it appears can be written like this:
{{"欢迎使用安企CMS(AnQiCMS)"|index:"CMS"}}
# 显示结果
18
Sample Demo
Calculate where a keyword appears in a line of text
Direct output result:
{{"欢迎使用安企CMS(AnQiCMS)"|index:"CMS"}}
# 显示结果
18
Calculate where a keyword appears in an array
The keywords in the array need to be equal to the value or index of the array, and they need to be completely equal and cannot be partially matched.
{% set values = "splits the string 安企CMS"|fields %}
{{values|index:"the"}}
# 显示结果
1
{% set values = "splits the string 安企CMS"|fields %}
{{values|index:"安企"}}
# 显示结果
-1