Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What if there is no picture, how to not show broken window? 1

Status
Not open for further replies.

kpierson

Technical User
Jul 13, 2000
9
US
I am doing a realestate site. The pictures are not listed in the MLS database. I am pulling up the pictures using:

<IMG HEIGHT=100 WIDTH=100 SRC=&quot;/mlspictures/VICTORIA#MLS#.jpg&quot;>

Where #MLS# is the Multiple Listing number. This works well until I run across a listing with no picture. I want to put a generic picture in place of where the picture goes. I have tried various ways using this:

<CFIF &quot;VICTORIA#MLS#.jpg&quot; IS &quot;&quot;>
<IMG HEIGHT=100 WIDTH=100 SRC=&quot;/mlspictures/nopictures.gif&quot;>

This doesn't work, before or after.
Any ideas how I can get my nopicture.gif to display if there is no picture?
 
Try taking the &quot;VICTORIA&quot; and &quot;.jpg&quot; out of your IF statement. The way it reads right now, VICTORIA#MLS#.jpg will never be &quot;&quot; because &quot;VICTORIA&quot; and &quot;.jpg&quot; have been hard coded and they already exist. Try:

<CFIF #MLS# IS &quot;&quot;>
<IMG HEIGHT=100 WIDTH=100 SRC=&quot;/mlspictures/nopictures.gif&quot;>
<cfelse>
<IMG HEIGHT=100 WIDTH=100 SRC=&quot;/mlspictures/VICTORIA#MLS#.jpg&quot;>
</cfif>



Hope This Helps!

Ecobb
- I hate computers!
 
The problem is that the listing exists, but the picture doesn't. You'll always have MLS numbers; you just won't always have pictures.

I don't see a clean way of doing this outside of using a CFDIRECTORY to get all of the image file names, and then doing a LISTFIND() on the file name column for that particular file.

(In your output loop)
<cfset thispic = &quot;VICTORIA&quot;&trim(MLS)&&quot;.jpg&quot;>
<cfif listfind(valuelist(mydirectoryquery.file),thispic) GT 0>
<IMG HEIGHT=100 WIDTH=100 SRC=&quot;/mlspictures/VICTORIA#MLS#.jpg&quot;>
<cfelse>
<IMG HEIGHT=100 WIDTH=100 SRC=&quot;/mlspictures/nopictures.gif&quot;>
</cfif>


HTH,

Phil Hegedusich
Senior Web Developer
IIMAK
-----------
Boy howdy, my Liberal Studies degree really prepared me for this....
 
Hi All,
First time posting here.
Is it possible to use solve by this method:
============== in application.cfm =======================
<cfset thisPath = ExpandPath(&quot;*.*&quot;)>
<cfset thisDirectory = GetDirectoryFromPath(thisPath)>
=========================================================


=========================================
<Cfif FileExists(&quot;#thisDirectory#mlspictures/VICTORIA#MLS#.jpg&quot;)>
<IMG HEIGHT=100 WIDTH=100 SRC=&quot;/mlspictures/VICTORIA#MLS#.jpg&quot;>
<cfelse>
&nbps;
</cfif>
 
<cfset thisPath = ExpandPath(&quot;*.*&quot;)>
<cfset thisDirectory = GetDirectoryFromPath(thisPath)>

shorter
\/\/\/\/

<cfset thisDirectory = GetTemplatePath()>

Pura Vida - &quot;The Pure Life&quot; - Visit Costa Rica
 
Uhh... no mcsolas...
Code:
GetTemplatePath()
returns the entire path including the filename.

You would still need to use the
Code:
GetDirectoryFromPath()
method to get just the directory. So it's no shorter than the
Code:
ExpandPath()
solution. They're pretty interchangable.


-Carl
 
OH yeah sorry. I forgot I pulled that from the form, not my cffile code. I have been using that to make a standard generic email me form that I copy from site to site.

Mike

Pura Vida - &quot;The Pure Life&quot; - Visit Costa Rica
 
Hi,

Please tell me if I have missed this, but how
(form, URL) is the #MLS# being passed into this template?

RR [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top