Re: [SMARTY] Problem with {if} and file_exists
| From: | Guillaume Justier | Date: | Wed, 07 May 2003 16:20:00 +0000 |
| Subject: | Re: [SMARTY] Problem with {if} and file_exists | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9495@lists.php.net to get a copy of this message | ||
Hi Andreas,
Maybe it is not exactly what you want but you could try the following:
- Test if the file exists in your php file.
- in your template, have just a variable {$image}
- create an $image var
- assign the $image to your template.
- if the image exists, assign
/home/shop/public/media/manufacturer/imagename.gif to $image.
-if the image doesn't exists, set $image to '' and nothing will be
displayed.
As a rule, I try to keep as much of the logic as possible inside the php
file rather than in the template.
I hope it helps,
Guillaume
www.inmeres.com
----- Original Message -----
From: "Andreas Ahlenstorf" <andreas.ahlenstorf@gmx.ch>
To: "Smarty List" <smarty-general@lists.php.net>
Sent: Wednesday, May 07, 2003 3:39 PM
Subject: [SMARTY] Problem with {if} and file_exists
> Hello,
>
> I have to check, if an image exists or not. I tried it with the
> following if statement, but it won't work. Is there any possibility to
> do that?
>
> {if
file_exists("/home/shop/public_html/media/manufacturer/".$article.item_manuf
acturer|lower.".gif")}
>
> Thanks for help,
> Andreas
>
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>