Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

{html_image} fichier non trouvé / fichier par défaut

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
azurams
Smarty n00b


Joined: 29 Dec 2006
Posts: 2

PostPosted: Fri Dec 29, 2006 12:56 pm    Post subject: {html_image} fichier non trouvé / fichier par défaut Reply with quote

Bonjour ,

j'utilise la balise {html_image file="/monchemin/monficher.png" } en spécifiant un fichier qui n'existe pas toujours. Smarty retourne donc une erreur précisant que le fichier monfichier.png n'a pas été trouvé.

Est-il possible de définir un fichier qui serait utilisé par défaut si smarty ne trouve pas le fichier physique précisé dans l'attribut 'file' ?
Back to top
View user's profile Send private message
jbenzakin
Smarty Rookie


Joined: 09 Nov 2006
Posts: 6
Location: austin

PostPosted: Fri Dec 29, 2006 8:03 pm    Post subject: possible :) Reply with quote

creer une variable dans le code php:
par exemple: $fichier = 'monficher.pg';

{if $fichier ne ''}
{html_image file="/monchemin/monficher.png" }
{else}
{html_image file="/monchemin/default.png" }
{/if}

bonne chance
jeremie
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
azurams
Smarty n00b


Joined: 29 Dec 2006
Posts: 2

PostPosted: Fri Dec 29, 2006 10:24 pm    Post subject: pas exactement Reply with quote

En fait, le souci est que quand je fourni le nom 'monfichier.png' je ne sais pas s'il existe physiquementdans le systeme de fichier.

Je pense que je vais faire un plugin smarty qui teste le type du fichier
et qui permettrait de faire ça:

{if $monfichier|is_file}
{html_image file=$monfichier }
{else}
{html_image file=$imagedefault }


ou alors, version plus compliquée, étendre la fonction {html_image} pour tester si l'attribut file fourni est is_file() et introduire un attribut default_file
Back to top
View user's profile Send private message
Nilshar
Smarty n00b


Joined: 18 Feb 2005
Posts: 1

PostPosted: Sat Mar 24, 2007 11:03 am    Post subject: Reply with quote

Je recherche exactement la meme chose, je veux tester si le fichier existe DANS le template et non dans le code php.
Est-ce possible ?
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP