Page 1 of 1
Smarty: checking for a file
Posted: Thu Feb 21, 2008 3:52 pm
by yellowled
Maybe I'm too stupid to follow the Smarty docs correctly, maybe it's just too early. Is there any way to check in a .tpl file whether a certain file (i.e. an image at a given location) exists at all?
YL
Re: Smarty: checking for a file
Posted: Thu Feb 21, 2008 4:13 pm
by garvinhicking
Hi!
No, the getFile check always falls back to the default name you submitted.
Can you describe the scenario you need that check for? In the past, such a function was not really needed.
Regards,
Garvin
Re: Smarty: checking for a file
Posted: Thu Feb 21, 2008 8:03 pm
by yellowled
garvinhicking wrote:Can you describe the scenario you need that check for? In the past, such a function was not really needed.
I'm working on a port which has a different start page than we usually have. It displays a certain category as "lead articles", another one as "features", and a third as "news", all of them as "teasers". All of these have an image associated with them which is not included in the entry. It's only shown on the index page.
My current approach to implement this is to make users upload images with the filename {$entry.id}.jpg to a selected directory, and it would be nice - although not actually necessary - to check whether the image to be included is actually present or not.
Of course, I'm open to other suggestions to implement this feature, maybe even using the media database, which would be the most comfortable way for users anyway.
YL
Re: Smarty: checking for a file
Posted: Thu Feb 21, 2008 8:43 pm
by garvinhicking
Hi!
My current approach to implement this is to make users upload images with the filename {$entry.id}.jpg to a selected directory, and it would be nice - although not actually necessary - to check whether the image to be included is actually present or not.
How about using custom entrproperties for that? A field with "news_image", "bla_image", "bla_image2" into which a user can pick a media database image? Then those fields are only filled if an image was entered. This also makes it unneccessary for people to upload images via FTP?
Apart from that, developing an event plugin would be the better way to go, then you could also easier define default images (maybe depending on the associated category, or whatever).
Regards,
Garvin
Re: Smarty: checking for a file
Posted: Thu Feb 21, 2008 9:47 pm
by yellowled
garvinhicking wrote:How about using custom entrproperties for that? A field with "news_image", "bla_image", "bla_image2" into which a user can pick a media database image? Then those fields are only filled if an image was entered. This also makes it unneccessary for people to upload images via FTP?
Sounds great. I'll look into that tomorrow.
garvinhicking wrote:Apart from that, developing an event plugin would be the better way to go, then you could also easier define default images (maybe depending on the associated category, or whatever).
Well, first of all: I may have svn access, but I'm still no PHP coder

Second, that would require people to have said plugin installed. Plus, why code another plugin if the funtionality is possibly already there?
I'll see what I can do using custom entry properties first.
YL
Posted: Fri Feb 22, 2008 9:22 am
by yellowled
Whoa. That's a
lot better than my approach to it
It's working great with a custom entry property - of course users will have to have the extended entry properties plugin installed and define the custom field themselves, but I figure that will be okay. I'll add an instructional text to the theme options, and people using this template will have to put in some more "extra work" to use it anyway, so it's fine.
Definitely no need to code an extra plugin providing the same functionality in my humble opinion, and thanks again, Garvin!
YL