Displaying uploads on events page

4 posts by 3 authors in: Forums > CMS Builder
Last Post: February 24, 2010   (RSS)

Re: [jab788] Displaying uploads on events page

By Damon - February 24, 2010

Hi,

Can you use the Code Generator (Admin > Code Generator) to generate code for your events section and then paste it as a reply?

This way I can see all the fields you have.

Here is a simple example code to output events with a thumbnail image:
<h2>Events</h2>

<table>
<?php foreach ($events_Records as $record): ?>
<tr>
<td>
<?php foreach ($record['image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
<?php endif ?>
<?php endforeach ?>
</td>
<td>
<?php echo $record['title'] ?><br/>
<?php echo date("D, M jS, Y", strtotime($record['date'])) ?><br/>
Event details: <?php echo $record['content'] ?><br/>
Etc....
</td>
</tr>
<?php endforeach ?>
</table>

Cheers,
Damon Edis - interactivetools.com

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

Re: [Damon] Displaying uploads on events page

By jab788 - February 24, 2010

Hey thank you for taking the time to help. Still can't figure this out! Here's my code:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "/home2/pittbull/public_html/warmemorial/cmsAdmin/lib/viewer_functions.php";

list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>

<!-- INSTRUCTIONS -->
<div class="instructions">
<b>Sample List Viewer - Instructions:</b>
<ol>
<?php ?>
<li><b>Remove any fields you don't want displayed.</b> (Most list pages only have title and link fields.)</li>
<li>Rearrange remaining fields to suit your needs.</li>
<li>Copy and paste code into previously designed page (or add design to this page).</li>
</ol>
</div>
<!-- /INSTRUCTIONS -->

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Events - List Page Viewer</h1>
<?php foreach ($eventsRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Date: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/>
<!-- For date formatting codes see: http://www.php.net/date -->
Content: <?php echo $record['content'] ?><br/>
Ticketmaster Link: <?php echo $record['evt_ticket'] ?><br/>
Venue: <?php echo $record['evt_venue'] ?><br/>
Month: <?php echo $record['evt_mo'] ?><br/>
Day: <?php echo $record['evt_day'] ?><br/>
Year: <?php echo $record['evt_yr'] ?><br/>
Time: <?php echo $record['evt_time'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>


<!-- STEP 2a: Display Uploads for field 'img' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['img'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->


<hr/>
<?php endforeach ?>

<?php if (!$eventsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

</body>
</html>

Re: [jab788] Displaying uploads on events page

By Dave - February 24, 2010

Hi jab788,

It looks right to me. And that's not displaying the images?

Let me know what's happening and I'll try to help.
Dave Edis - Senior Developer
interactivetools.com