PDA

View Full Version : Template: Determine if file exists possible?


Sven
04-02-2008, 10:29 AM
I have the following conditional for a hack:
<if condition="$attachment['replay']['official']">
<img src='images/mappics/{$attachment[replay][picname]}.png' style='width:200px; height:200px; margin:3px;' alt='{$attachment[replay][picpname]}' />
<else />
<img src='images/mappics/unofficial.jpg' style='width:200px; height:200px; margin:3px;' alt='{$attachment[replay][mapname]}' />
</if>
It's about a replay and wether the used map is an official one or not.
If the map is an official one the picture of the map is displayed, if not a placeholder picture.
Now we want to display, one after the other, also pictures of unofficial maps - of course only if the file for the map exists.

Question: Is it possible to create something in a template that is looking into a specified folder in order to check wether a file is present or not?

Marco van Herwaarden
04-02-2008, 10:35 AM
That would be easier to do with a small bit of PHP in a plugin.

Boofo
04-02-2008, 11:23 AM
In the plug-in use:

$show['something'] = file_exists('./yourfolder/yourfile.php');

In the template use:


<if condition="$show['something']">
do this
</if>