'Where' to find an answer!

18 posts by 4 authors in: Forums > CMS Builder
Last Post: October 23, 2008   (RSS)

By Perchpole - July 5, 2008

DAve -

Amazing. You've cracked it yet again!

This is the code I'm using to display the the uploads and associated data:

<?php foreach ($uploadRecords as $record): ?>
<a href="<?php echo $product[/#ff0000]['_link'] ?>"><IMG SRC="<?php echo $record[/#ff0000]['thumbUrlPath'] ?>" />
<BR />
<?php echo $product[/#ff0000]['title'] ?></a>
<?php endforeach ?>


The only thing you need to remember is to put the right placeholders[/#ff0000] in the right places - otherwise things get a bit muddled!

Just one final request on this topic: could you conjure-up a version of your code using the modern CMSB format, please?

:0)

Perch

Re: [Perchpole] 'Where' to find an answer!

By Dave - July 7, 2008

Perch, here's the code in modern format. Note that I don't have all your sections setup locally so this is untested.

// load upload
list($uploadRecords, $uploadMetaData) = getRecords(array(
'tableName' => 'uploads',
'where' => 'tableName = "products_classic" && fieldName = "images"',
'orderBy' => 'RAND()',
'limit' => '1',
));
$upload = @$uploadRecords[0]; // get first record

// load record
$recordNum = @$upload['recordNum'];
list($productRecords, $productMetaData) = getRecords(array(
'tableName' => 'products_classic',
'where' => "num = '$recordNum'",
'limit' => '1',
));
$product = @$productRecords[0]; // get first record


Let me know how it goes! :)
Dave Edis - Senior Developer
interactivetools.com

By Perchpole - July 8, 2008

Hi, Dave (and Jake) -

Thanks for your help with this matter. I've used both versions of the code to create random image pages - and both work very well.

However, there is one small issue which is rather interesting...

The code works by pulling images from the Uploads table. Trouble is, this includes images which belong to records that have been deleted! I checked the Upload table via phpmyadmin and, sure enough, all the images I've uploaded are still present.

As a work around I've added some more code to the Uploads' "where" condition - which seems to do the trick.

It's not really an issue but it is interesting to learn that the Uploads stay around even when the records associated with them have been erased!

Thanks, again, for your help.

:0)

Perch

Re: [Perchpole] 'Where' to find an answer!

By Dave - July 8, 2008

Hi perch,

Thanks for reporting that. Uploads should be erased with records in all cases. I'll do some tests on that locally and fix it for the next version if needed.
Dave Edis - Senior Developer
interactivetools.com

Re: [jposwald] 'Where' to find an answer!

By Dave - October 22, 2008

Hi Juan,

A quick question first - what version of CMS Builder are you running?
Dave Edis - Senior Developer
interactivetools.com

By jposwald - October 22, 2008

Dave,

I'm running 1.22 version.

Re: [jposwald] 'Where' to find an answer!

By Dave - October 23, 2008

Try this:

<?php echo $videos['title'] ?>
<?php echo $videos['description'] ?>

Let me know if that fixes it.
Dave Edis - Senior Developer
interactivetools.com