Using a pic as the link in a combo page

4 posts by 2 authors in: Forums > CMS Builder
Last Post: August 20, 2018   (RSS)

By mattbcd - July 16, 2018

Hi. I've been trying to work this out to no avail.

I have a site which sell books.  On one page has all the current books, linked to a detail page, which gives more detail on that book. Fine so far.

At the bottom of that detail page, I want a list of all of the other books available, as per a combo page. 

However rather than the list being text, I want them to be pics (possibly thumbnail, possibly not), which can be clicked on to go through to that product.

Is this possible using a combo page?  The only fields I appear to be able to use are text fields.

Any help greatly appreciated!

By leo - July 16, 2018

Hi,

The combo page generator does not support this feature by default, However, you can make it happen by a few simple steps:

1. In the combo page, find where the getRecords() is called for "text list" records and change the "loadUploads" option to be true. By default, it will look something like this:

list($booksRecords, $booksMetaData) = getRecords(array(
'tableName'   => 'books',
'loadUploads' => true,
'allowSearch' => false,
));

2. Find where the "text list" is generated. Modify the list to show image uploads or whatever information you want for the list:

<!-- STEP2: Display Record List (Paste this where you want your record list) -->
    <b>Record List</b><br/>
    <?php foreach ($booksRecords as $listRecord): ?>
      <?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
      <?php if ($isSelected) { print "<b>"; } ?>
      <a href="<?php echo htmlencode($listRecord['_link']) ?>"><img src="<?php echo $listRecord['images'][0]['urlPath'] ?>" /></a><br/>
      <?php if ($isSelected) { print "</b>"; } ?>
    <?php endforeach ?>

If you want to use the thumbnail instead of the original image, change "urlPath" to "thumbUrlPath".

Let me know if you got any questions!

Leo - PHP Programmer (in training)
interactivetools.com

By mattbcd - July 16, 2018

Mate, you're a lifesaver!

I'll give it a try and report back.