Displaying Images (not loaded into CMSB)

2 posts by 2 authors in: Forums > CMS Builder
Last Post: May 25, 2011   (RSS)

By sidcam - May 24, 2011

My CMSB database has 20,000+ records (real estate listings) being imported into it. It is updated daily. The photos that go with the records are imported into a directory on the server (basically, "/html/mlsphotos/"). The photos are NOT loaded into the CMSB database.

I need to be able to display the photos with their corresponding record. Although the name of the photos match an existing CMSB field that is unique to each records, (i.e. <listingnumber>_1.jpg, <listingnumber>_2.jpg, etc) my problem is that every record has a unique number of photos (up to 99). So if I hardcode my page to allow for 99 photos and there's only 1, I'm displaying 98 broken/missing images.

There is a second field named <picturecount> that tells me the exact number of photos that the record has. Is there a simple way to make CMSB read the <picturecount> field and repeat a series of html to display the correct number of photos for each listing?

Thanks in advance, Sid

Re: [sidcam] Displaying Images (not loaded into CMSB)

By Damon - May 25, 2011 - edited: May 25, 2011

Hi,

What about using the PHP file_exists function to check if the image exists, and then if it does display the image?

Here is the file_exists function detail page on php.net:
http://php.net/manual/en/function.file-exists.php

Then you can loop through one number at a time until you reach the picturecount, then break.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/