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
Smarty: checking for a file
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Smarty: checking for a file
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
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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Smarty: checking for a file
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.garvinhicking wrote:Can you describe the scenario you need that check for? In the past, such a function was not really needed.
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
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Smarty: checking for a file
Hi!
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
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?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.
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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Smarty: checking for a file
Sounds great. I'll look into that tomorrow.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?
Well, first of all: I may have svn access, but I'm still no PHP codergarvinhicking 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).
I'll see what I can do using custom entry properties first.
YL
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
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