Question

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?

Was it helpful?

Solution 2

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 }}

OTHER TIPS

You should use the same curly braces for the name variable as you are for the id:

{{ files:listing folder='1' }}
    {{ if { helper:strpos haystack='{{ name }}' needle='_blur' } }}
        {{ files:image id='{{ id }}' }}
    {{ endif }}
{{ /files:listing }}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top