need dynamic path in file-exists query
Posted: Fri Nov 14, 2008 6:24 pm
I need to find whether a file exists (an image) and then display it if it does exist or ignore if it does not. That is easy enough. The problem is that the name of the image I want to discover is not a constant but dynamically determined.
So I need something like this:
However the value for the articleImg variable is never valid because of the variable used in the path.
This is probably a simple syntax issue, but I am just not getting this to work.
Any ideas?
So I need something like this:
Code: Select all
{assign var="articleImg" value="uploads/images/{$entry->title}.jpg"}
{ if file_exists($articleImg) }
<a href="{$entry->link}"><img src="uploads/images/{$entry->title}.jpg"
alt="{$entry->title}" /></a>
{/if}
This is probably a simple syntax issue, but I am just not getting this to work.
Any ideas?