[ic] howto do if file exists

Nicholas Cook interchange-users@icdevgroup.org
Thu Apr 17 11:44:01 2003


---------Included Message----------
>Date: 16-Apr-2003 23:52:47 -0400
>From: "Mike Heins" <mike@perusion.com>
>Reply-To: <interchange-users@icdevgroup.org>
>To: <interchange-users@icdevgroup.org>
>Subject: Re: [ic] howto do if file exists
>
>Quoting Marty Tennison (marty@sediva.com):
>> On Wed, 2003-04-16 at 18:50, Nicholas Cook wrote:
>> > Currently I have the following in my results page.
>> > 
>> > <td width=86>
>> >     <a href="[area [item-code]]">
>> >        [if-item-field thumb]
>> >           <img border="0" src="thumb/[item-field thumb]">
>> >        [else]
>> >           <img border="0" src="thumb/80.gif">
>> >        [/else]
>> >        [/if-item-field]
>> >     </a>
>> > </td>
>> > 
>> > My question is how would you do "If file exists" instead of the above 
>> > if-field exists?  In other words, I want to test if the image file 
>> > exists, and if so display the image.  If not, display the default image.
>> > 
>> > The other question with this is if I can do a "if file exists" clause, 
>> > how resource intensive is that.  If people feel that this would be too 
>> > slow, what other solutions do people know of. (The only other one I can 
>> > think of is to setup a crontab entry to update specific fields in the 
>> > database nightly, according to the contents of specific directories.)
>> > 
>> > Thank you,
>> > Nicholas Cook
>> 
>> With interchange markup it might look something like this
>> 
>> [if type=file term="some_dir/some_dir/[item-code].jpg"]
>> 	Yep it's here
>> [else]
>> 	Nope it aint
>> [/else]
>> [/if]
>> 
>
>Yes, this works well and is not too bad for resource usage,
>as those read-only directories will just about always be
>in cache on a busy system. It will *not* be so good if
>you have thousands of files in the directory.
>
>There is also another way in Apache:
>
>    <Location /cat/images/thumb>
>	ErrorDocument 404 /cat/images/thumb/80.gif
>    </Location>
>
>Not really very portable, as you have to remember to mess with
>your Apache configuration. But it works well...if you use .htaccess
>it might even transfer with the directory.
>
>-- 
>Mike Heins
>Perusion -- Expert Interchange Consulting    http://www.perusion.com/
>phone +1.513.523.7621      <mike@perusion.com>
>
>Software axiom: Lack of speed kills.
>_______________________________________________
>interchange-users mailing list
>interchange-users@icdevgroup.org
>http://www.icdevgroup.org/mailman/listinfo/interchange-users
>
>
---------End of Included Message----------

I hadn't thought about using apache.  I'll try that approach because I am talking about 20,000+ images.

Thank you,
Nicholas Cook