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
Re: [4cdg] display record if it has upload
By Jason - July 28, 2011
It's not really easy to add this to the where clause, since uploads are actually stored in a separate table from the rest of the information in your section.
A better way is to just skip over records with no uploads as you're looping through them. For example, if you had records from a news section, and the news section had an upload field called "images", your code could look like this:
<?php foreach ($newsRecord as $record): ?>
<?php if (!$record['images']) { continue; } // skip records with no images ?>
// output information from $record here.
<?php endforeach ?>
Hope this helps get you started.
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
any ideas.
url is test.stoddardmls.com
Re: [4cdg] display record if it has upload
By Jason - July 28, 2011
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
Thanks