Include additional table
5 posts by 2 authors in: Forums > CMS Builder
Last Post: August 2, 2017 (RSS)
By dlsweb - July 28, 2017
Unfortunate;y I am at a loss how to accomplish.
I have the below to show Features with a top_photo in my festivals table.
Can you please tell me how to also include in the random display Features in my Vendor table with a top_photo.
Thanks in advance
Larry
// load records for featured festivals
list($festivalsRecordsFEATURED, $festivalsMetaData) = getRecords(array(
'tableName' => 'festivals',
'where' => ' featured LIKE "1" ', // if checkbox for featured is checked
'limit' => '5',
'orderBy' => 'RAND()',
'loadUploads' => true,
'allowSearch' => false,
));
<?php foreach ($festivalsRecordsFEATURED as $record): ?>
<?php if ($record['top_photo']) : ?>
<?php foreach ($record['top_photo'] as $index => $upload): ?>
<p><a href="<?php echo $record['_link'] ?>">
<img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<br />
<?php echo htmlencode($record['title']) ?>
</p>
<?php endforeach ?>
<?php endif; ?>
<?php endforeach ?>
By Dave - July 28, 2017
Hi dlsweb,
Can you please tell me how to also include in the random display Features in my Vendor table with a top_photo.
Can you just duplicate the code, eg:
// load records for featured vendors
list($vendorsRecordsFEATURED, $vendorsMetaData) = getRecords(array(
'tableName' => 'vendors',
'where' => ' featured LIKE "1" ', // if checkbox for featured is checked
'limit' => '5',
'orderBy' => 'RAND()',
'loadUploads' => true,
'allowSearch' => false,
));
<?php foreach ($vendorsRecordsFEATURED as $record): ?>
<?php if ($record['top_photo']) : ?>
<?php foreach ($record['top_photo'] as $index => $upload): ?>
<p><a href="<?php echo $record['_link'] ?>">
<img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<br />
<?php echo htmlencode($record['title']) ?>
</p>
<?php endforeach ?>
<?php endif; ?>
<?php endforeach ?>
Would that work for you?
interactivetools.com
By dlsweb - July 28, 2017
I wasn't clear
I would like features from my festival table
and
features from my vendors table to both be in the roattion
By Dave - August 1, 2017
Hi dlsweb,
Could you combine both arrays into one? Do both sections have the same fields?
// combine two recordsets into one
$featuredRecords = array_merge($festivalsRecordsFEATURED, $vendorsRecordsFEATURED);
...
<?php foreach ($featuredRecords as $record): ?>
Or if the seconds are the same, maybe add a field called "Type" that can be of value: festival or vendor.
interactivetools.com