Help with thumbnail displays

7 posts by 3 authors in: Forums > CMS Builder
Last Post: March 20, 2008   (RSS)

By mateo - March 14, 2008

I have exactly what I want hard coded at http://thomaspaintingllc.com/references.php

I just want to make the two images on the left sidebar editable by CMSBuilder. I've set up a section called sidebar_images and set the thumbnail size to be right for these, but I can't figure out how to call those thumbnails correctly.

What's the correct way to call the thumbnails and info1 text for both images and not interfere with my page content call?

Thanks in advance for the help!

Re: [mateo] Help with thumbnail displays

By Dave - March 14, 2008

Hi mateo! :)

You have sidebar images throughout the site right?

I'd suggest adding a field called 'section'. Then give it a value of 'services' and upload all the images for the services page on that record.

Then just use a regular page viewer to show the images like this. The only difference is we'll rename some of the variables.

<?php
require_once "lib/viewer_functions.php";
$sidebarOptions = array();
$sidebarOptions['tableName'] = 'sidebar_images';
$sidebarOptions['recordNum'] = ''; // use where below:
$sidebarOptions['where'] = 'section = "services"';
$sidebarRecord = getRecord($sidebarOptions);
?>


Then display your images like this:

<?php foreach getUploads($sidebarOptions['tableName'], 'uploads', $sidebarRecord['num']) as $upload) ?>

<img src="<?php echo $upload['thumbUrlPath'] ?>"
width="<?php echo $upload['thumbWidth'] ?>"
height="<?php echo $upload['thumbHeight'] ?>"
alt="" /><br/>
<?php echo $upload['info1'] ?><br/>

<?php endforeach ?>


See if you can get that far and let me know how it goes. If that works well you can add a record 'sidebar_images' for each page on the site (and add viewers for them).

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

Re: [Dave] Help with thumbnail displays

By mateo - March 14, 2008

OK, set that all up and I'm getting this error:

Parse error: syntax error, unexpected T_STRING, expecting '(' in /mnt/Target01/337632/351436/www.thomaspaintingllc.com/web/content/test.php on line 75


Here is what I have for php code. (Line 75 is the "foreach getuploads" line:


<?php
require_once "lib/viewer_functions.php";
$sidebarOptions = array();
$sidebarOptions['tableName'] = 'images';
$sidebarOptions['recordNum'] = ''; // use where below:
$sidebarOptions['where'] = 'Page = "references"';
$sidebarRecord = getRecord($sidebarOptions);
?>

and


<?php foreach getUploads($sidebarOptions['tableName'], 'uploads', $sidebarRecord['num']) as $upload) ?>

<img src="<?php echo $upload['thumbUrlPath'] ?>"
width="<?php echo $upload['thumbWidth'] ?>"
height="<?php echo $upload['thumbHeight'] ?>"
alt="" /><br/>
<div class="caption"><p>
<?php echo $upload['caption'] ?><br/>
</p></div>


<?php endforeach ?>

Re: [mateo] Help with thumbnail displays

By Dave - March 15, 2008

Ahh, sorry about that typo. Change this (add "(" before getUploads and ":" after $upload)):

<?php foreach (getUploads($sidebarOptions['tableName'], 'uploads', $sidebarRecord['num']) as $upload): ?>

and if you still get errors make sure require_once is set to the right path for your server (just copy the line from one of your other viewers or the code generator):

require_once "/path/on/your/server/lib/viewer_functions.php";

And for your caption used 'info2' (or which ever info field your caption is stored in, info2 is default) like this:

<?php echo $upload['info2'] ?>

Hope that helps! Let me know if there's any other problems with that.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Help with thumbnail displays

By mateo - March 20, 2008

Now I'm getting this:

Page Viewer (images): MySQL Error: Unknown column 'Page' in 'where clause'

Yet, in the screenshot below you can see that I have these fields..
Attachments:

picture-1_001.png 78K

Re: [mateo] Help with thumbnail displays

By Dave - March 20, 2008

Hi Mateo,

Try replacing $upload['Page'] with $upload['info2'].

All the extra upload "info" fields are named info1, info2, etc. The name you specify is just for display purposes only when the user is uploading images.

When modifying code just use the 'info#' fieldname that is displayed beside the field in the field editor.

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