CMS Builder photo gallery - newest image first?

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 19, 2009   (RSS)

Hi, there.

I have a client's photo gallery that is updated using CMSB: http://www.carv.ca/galleryPage.php. Is there a way to set this up so the most recently added images appear first? At the moment the oldest images are shown at the top and the latest are at the bottom.

Thanks!
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] CMS Builder photo gallery - newest image first?

By Dave - February 17, 2009

Hi Nigel,

You can reverse the order with array_reverse().

If your current code looks something like this:
<?php foreach ($record['uploads'] as $upload): ?>

Just add this code in red:
<?php foreach (array_reverse($record['uploads']) as $upload): ?>

Let me know if that works for you!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] CMS Builder photo gallery - newest image first?

Hi, Dave.

Sorry, I can't find any code similar to the first snippet in your reply. Here's the code I'm using (based on Lightbox 2.0):

======

<DIV ALIGN="CENTER">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- STEP1: Load Record (Paste this above other step) -->
<?php
require_once "/home/chicopee/public_html/cmsBuilder/lib/viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these options
$options['tableName'] = 'gallery'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$options['recordNum'] = ''; // (optional) Record number to display. Example: "1"; Defaults to number on end of url, then 1
$options['where'] = ''; // (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up record. Example: "fieldname = 'value'"
$record = getRecord($options);
?>
<!-- /STEP1: Load Record -->



<!-- STEP2: Display Record (Paste this where you want your record displayed and re-arrange fields) -->
<?php if ($record): ?>
<?php endif ?>

<?php if (empty($record)): ?>
<!-- Display "No Records Found" Message -->
<?php endif ?>
<!-- STEP2: /Display Record -->



<!-- STEP3: Display Uploads from 'content' (Paste this where you want your uploads displayed) -->
<?php foreach (getUploads($options['tableName'], 'content', $record['num']) as $upload): ?>

<?php if ($upload['hasThumbnail']): ?>
<A HREF="<?php echo $upload['urlPath'] ?>" REL="lightbox[roadtrip]" TITLE="<?php echo $upload['info1'] ?>">
<IMG SRC="<?php echo $upload['thumbUrlPath'] ?>" WIDTH="<?php echo $upload['thumbWidth'] ?>" HEIGHT="<?php echo $upload['thumbHeight']?>" BORDER="0" CLASS="imgGalleryThumbnail" /></A>

<?php elseif ($upload['isImage']): ?>
<A HREF="<?php echo $upload['urlPath'] ?>" REL="lightbox[roadtrip]" TITLE="<?php echo $upload['info1'] ?>">
<IMG SRC="<?php echo $upload['urlPath'] ?>" WIDTH="<?php echo $upload['width'] ?>" HEIGHT="<?php echo $upload['height'] ?>" BORDER="0" /></A>

<?php else: ?><?php endif ?>
<?php endforeach ?>
</DIV>

======

Thanks,
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] CMS Builder photo gallery - newest image first?

By Dave - February 18, 2009

Hi Nigel,

That's the original style of code we generated from earlier versions, but it's still very simular:

<?php foreach (array_reverse(getUploads($options['tableName'], 'content', $record['num'])) as $upload): ?>

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com