Use two upload fields in a listing

5 posts by 3 authors in: Forums > CMS Builder
Last Post: July 8, 2020   (RSS)

By Deborah - July 6, 2020

Hi, furcat,

Here's how I would set that up:

<?php foreach ($test_itemsRecords as $record): ?>

<?php foreach ($record['pdf'] as $index => $upload): ?>

<a href="<?php echo htmlencode($upload['urlPath']) ?>">

<?php foreach ($record['cover_photo'] as $index => $upload): ?>
<img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt=""></a>
<?php endforeach ?>

<?php endforeach ?>
<?php echo htmlencode($record['title']) ?>

<?php endforeach ?>

All of the above code is available in the CMSB Code Generator - it just needs to be juggled around to wrap the image with the PDF urlPath.

~ Deborah

By gregThomas - July 7, 2020 - edited: July 7, 2020

Hey Furcat,

To expand on Deborah's answer a bit, I'd create two upload fields, one that contains the book cover image called 'cover_image' and one that contains the book PDF called 'pdf'. I'd limit the fields so that each can only contain one upload. With this setup, Deborah's code would return one image and pdf per book record.

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By furcat - July 8, 2020

Thank you! Worked perfectly. I really appreciate it.

Now I need to figure out how to make two columns ..... 

By furcat - July 8, 2020

Thank you! Worked perfectly.