Search code examples
loopsconditional-statementspyrocmsstrpospyrocms-lex

Display images in PyroCMS depending on its {{ name }}-tag


I need to display some images from a folder depending on its {{ name }}.

The names of my files look like this:

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

Now I need to do something with the blurred-image. This is what I tried, but no success:

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

Currently it just does nothing. It seems that the strpos returns allways false. Any ideas what I'm doing wrong?


Solution

  • Got it by myself, thanks to Leon Stafford:

    Just remove the brackets [[ ]] and its surrounding quotes

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