|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
azurams Smarty n00b
Joined: 29 Dec 2006 Posts: 2
|
Posted: Fri Dec 29, 2006 12:56 pm Post subject: {html_image} fichier non trouvé / fichier par défaut |
|
|
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 |
|
jbenzakin Smarty Rookie
Joined: 09 Nov 2006 Posts: 6 Location: austin
|
Posted: Fri Dec 29, 2006 8:03 pm Post subject: possible :) |
|
|
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 |
|
azurams Smarty n00b
Joined: 29 Dec 2006 Posts: 2
|
Posted: Fri Dec 29, 2006 10:24 pm Post subject: pas exactement |
|
|
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 |
|
Nilshar Smarty n00b
Joined: 18 Feb 2005 Posts: 1
|
Posted: Sat Mar 24, 2007 11:03 am Post subject: |
|
|
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 |
|
|
|
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
|