美文网首页
Twig之截取字符串

Twig之截取字符串

作者: Cute_小肥鸡 | 来源:发表于2020-06-22 17:49 被阅读0次
slice()截取content变量值,从0到100

例如:截取字符串 “BK_2_1_01_06”中 的 “BK” 和 “06”,显示不同的图片

{% if TPL['classificationCode']|slice(0,2)=='BK' and TPL['classificationCode']|slice(10,12)=='01' %}
<!--开学考试-->
<img width="65" height="65" src="{{ context_path }}statics/images/tp_kaixue.png">
{% elseif TPL['classificationCode']|slice(0,2)=='BK' and TPL['classificationCode']|slice(10,12)=='02' %}
<!--月考试卷-->
<img width="65" height="65" src="{{ context_path }}statics/images/tp_yuekao.png">
{% elseif TPL['classificationCode']|slice(0,2)=='BK' and TPL['classificationCode']|slice(10,12)=='03' %}
<!--期中考试-->
<img width="65" height="65" src="{{ context_path }}statics/images/tp_qizhong.png">
{% elseif TPL['classificationCode']|slice(0,2)=='BK' and TPL['classificationCode']|slice(10,12)=='04' %}
<!--期末考试-->
<img width="65" height="65" src="{{ context_path }}statics/images/tp_qimo.png">
{% elseif TPL['classificationCode']|slice(0,2)=='BK' and TPL['classificationCode']|slice(10,12)=='05' %}
<!--复习试卷-->
<img width="65" height="65" src="{{ context_path }}statics/images/tp_fuxi.png">
{% elseif TPL['classificationCode']|slice(0,2)=='BK' and TPL['classificationCode']|slice(10,12)=='06' %}
<!--竞赛测试-->
<img width="65" height="65" src="{{ context_path }}statics/images/tp_jingsai.png">
{% endif %}

相关文章

网友评论

      本文标题:Twig之截取字符串

      本文链接:https://www.haomeiwen.com/subject/zylffktx.html