I'm using the Smarty php template engine, and I'm trying to verify the existence of .jpg images with an $id_attribute
name:
{foreach from=$product.colors key='id_attribute' item='color'}
{if file_exists($img_col_dir|cat:$id_attribute|cat:'.jpg')}
yes
{else}
no
{/if}
The $img_col_dir
is "http://www.domain.com/img/co/" and $id_attribute
is a number. Many files exists in .jpg format, but the whole loop doesn't find anything, returning "no". What am I doing wrong?
You can't check for existance of a file on a url,
http://www.domain.com/img/co/myfile.jpg
only on your local drive
c:\myfolder\myimages\myfile.jpg
also, you should do this logic in your php file, not in your smarty template.
Check if the file exists then pass through a smarty variable image_exists for each image.