2013-09-24 46 views
0

我需要根据文件夹{{ name }}显示一些文件夹中的图像。在PyroCMS中显示图像取决于它的{{name}} - 标记

我的文件的名称是这样的:

  • foo.jpg
  • foo_blur.jpg
  • bar.png
  • bar_blur.png

现在我需要用模糊 - 图像做一些事情。这是我试过的,但没有成功:

{{ files:listing folder='1' }} 
    {{ if { helper:strpos haystack='[[ name ]]' needle='_blur' } }} 
     {{ files:image id='{{ id }}' }} 
    {{ endif }} 
{{ /files:listing }} 

目前它什么也没做。看来strpos总归返回false。任何想法我做错了什么?

回答

0

由我自己明白了,这要归功于莱昂斯塔福德:

只需卸下支架[[ ]]其周边quotes

{{ files:listing folder='1' }} 
    {{ if { helper:strpos haystack=name needle='_blur' } }} 
     {{ files:image id='{{ id }}' }} 
    {{ endif }} 
{{ /files:listing }} 
+0

不用谢我,我的解决方案是不正确的。但很高兴你得到它:) –

0

因为你们是id你应该使用相同的花括号为name变量:

{{ files:listing folder='1' }} 
    {{ if { helper:strpos haystack='{{ name }}' needle='_blur' } }} 
     {{ files:image id='{{ id }}' }} 
    {{ endif }} 
{{ /files:listing }} 
+0

试过了,这个结果in和parsing-error:'你的Lex标签中有语法错误。' – yckart

+0

明白了! http://stackoverflow.com/a/18993853/1250044 – yckart