gallery

8 posts by 2 authors in: Forums > CMS Builder
Last Post: September 13, 2010   (RSS)

By 5fish - September 9, 2010

Q1/ Trying to create a gallery which when clicking on a List Page Viewer page thumbnail image will give me a page with the original image on the Detail Page Viewer. I am new to this ... I have the List Page Viewer page created but the thumbnails seem permanent!

http://www.petersmithconstruction.ca/gallerylist.php

Q2/ Would like to have thumbnails in a table format and be able to link from one List Page Viewer page to a 2nd and so on.

Re: [5fish] gallery

By Chris - September 9, 2010

Hi 5fish,

So you'd like to have your list viewer show a 5x5 table of thumbnails, one from each record, and next/prev buttons to get to the next 25 records? Also, you want the full-sized images to show on the detail pages? Do I have this right?

Please post the complete PHP source code of both your list and detail pages and I'll show you what to change to get this happening. :)
All the best,
Chris

Re: [chris] gallery

By 5fish - September 13, 2010

Exactly! Thank you!

Re: [5fish] gallery

By Chris - September 13, 2010

Hi 5fish,

At the top of your List viewer, in STEP 1, you'll want to add the line in red below:

// load records
list($galleryRecords, $galleryMetaData) = getRecords(array(
'tableName' => 'gallery',
'perPage' => 25,
));


Next, you can use this code in place of your STEP 2:

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Gallery - List Page Viewer</h1>
<table>
<tr>
<?php $count = 0 ?>
<?php foreach ($galleryRecords as $record): ?>

<?php if ($count++ % 5 == 0): ?></tr><tr><?php endif ?>

<!-- STEP 2a: Display Uploads for field 'photo_image' (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['photo_image'] as $upload): ?>
<td>
<a href="<?php echo $record['_link'] ?>">
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
</a>
</td>
<?php break ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->

<?php endforeach ?>
</tr>
</table>
<!-- /STEP2: Display Records -->

<!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
<?php if ($galleryMetaData['prevPage']): ?>
<a href="<?php echo $galleryMetaData['prevPageLink'] ?>">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>

- page <?php echo $galleryMetaData['page'] ?> of <?php echo $galleryMetaData['totalPages'] ?> -

<?php if ($galleryMetaData['nextPage']): ?>
<a href="<?php echo $galleryMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?php endif ?>
<!-- /STEP3: Display Page Links -->


Finally, on your detail page, replace STEP 2a with:

<!-- STEP 2a: Display Uploads for field 'photo_image' (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['photo_image'] as $upload): ?>
<a href="<?php echo $upload['urlPath'] ?>">
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
</a>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [5fish] gallery

By 5fish - September 13, 2010

It works! except for the fact that I cannot get my thumbnails to display. They end up in the thumbs directory, but whenever I select create thumbnails, it displays the thumbnails in the "detail" page as well as the list page.
If I don't select create thumbnails I do not get a thumbnail on "list" page but I do get the image to display properly on "detail" page.
List page = http://www.petersmithconstruction.ca/glist.php
-------------------
The way it is now - I get an error on "detail" page as follows (I assume I am missing an arguement)

Notice: Undefined variable: record in /home/.sites/145/site102/web/gallerydetail.php on line 81 Warning: Invalid argument supplied for foreach() in /home/.sites/145/site102/web/gallerydetail.php on line 81
-------------------

Do I need a separate thumbnail upload?

Re: [5fish] gallery

By Chris - September 13, 2010 - edited: September 13, 2010

Hi 5fish,

The error was my fault. I forgot to change the record variable from $record to $galleryRecord. The code I gave you was meant to show thumbnails again on the detail page, but have them link to full-size images. If you want to have the images display full-size on your detail page, replace STEP 2a on your detail page with this:

<!-- STEP 2a: Display Uploads for field 'photo_image' (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 ($galleryRecord['photo_image'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /> <br />
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->


Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [chris] gallery

By 5fish - September 13, 2010

Awesome! Much appreciated.
Ted