Having uploads show in list veiwer

4 posts by 2 authors in: Forums > CMS Builder
Last Post: March 19, 2008   (RSS)

Re: [justritedesign] Having uploads show in list veiwer

By Dave - February 15, 2008

You're on the right track. Just copy and paste the block of code that displays uploads (from the page viewer) and past it _inside_ the foreach loop that displays your record.

So for your viewer that would be like this:

<?php foreach ($listRows as $record): ?>
<?php echo $record['content'] ?><br/>

Copy and paste upload display code here.

<?php endforeach ?>


Then it will display the uploads or attachments for each record.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Having uploads show in list veiwer

By Mohaukla - March 19, 2008

I have created the list page and it works fine but I am wondering if there is a way to have only one thumbnail show instead of all the uploaded images that were uploaded.
http://www.willmarairservice.com/listings.php
<?php if ($record): ?>
<?php foreach (getUploads($options['tableName'], 'uploads', $record['num']) as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" border="0" onmousedown="MM_swapImage('picture','','<?php echo $upload['urlPath'] ?>',1)" />
<!-- <span class="t12_white"><?php echo $upload['info1'] ?></span><br />-->
<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['info1'] ?></a><br/>
<?php endif ?>
<?php endforeach ?>

Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

Re: [justritedesign] Having uploads show in list veiwer

By Dave - March 19, 2008

You bet, PHP has a function for "breaking" out of a foreach loop called 'break'. Also, if you're never going to have anything but thumbnails you can remove the code that shows download links (keep it if you need it). Try this:

<?php foreach (getUploads($options['tableName'], 'uploads', $record['num']) as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" border="0" onmousedown="MM_swapImage('picture','','<?php echo $upload['urlPath'] ?>',1)" />
<!-- <span class="t12_white"><?php echo $upload['info1'] ?></span><br />-->
<?php break; ?>
<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['info1'] ?></a><br/>
<?php endif ?>
<?php endforeach ?>


Basically, it won't see the break() code until the first time it shows a thumbnail, then it will "break" out of the loop and won't show anything else. You can use break() in any foreach loops when you want to show just one of something.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com