display record if it has upload

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 28, 2011   (RSS)

By 4cdg - July 28, 2011

I currently have several sites that will list the newest records on their homepage. I understand how to display something if a record doesn't have an image uploaded (like a default image) but what we would really like to do is not display the record at all if no upload is present, so basically if the record doesn't have anything uploaded it wouldn't display on the homepage. I believe it would need to be in the where statement where i filter other things but not sure how to code.

Re: [Jason] display record if it has upload

By 4cdg - July 28, 2011

that sort of worked. It removed the record with no upload, but instead of another record taking its place, it leaves a empty spot. I have the page setup to pull the 8 newest listings added to the cms using the created date. I have 11 records in the database and only one has no upload. The one with no upload now does not display, but only 7 records are showing up on the page.

any ideas.

url is test.stoddardmls.com

Re: [4cdg] display record if it has upload

By Jason - July 28, 2011

Hi,

One thing you can try is to return all your records, and use a counter to decide when to stop outputting.

for example:

<?php
$maxRecords = 8;
$recordCount = 0;
?>
<?php foreach ($newsRecord as $record): ?>
<?php if (!$record['images']) { continue; } // skip records with no images ?>
<?php if ($recordCount == $maxRecords) { break; } ?>
<?php $recordCount ++; ?>

// output information from $record here.
<?php endforeach ?>

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] display record if it has upload

By 4cdg - July 28, 2011

That worked like a charm!

Thanks