Feature Gallery Photo on other site pages

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 25, 2013   (RSS)

By Mikey - March 23, 2013

I'm a bit stumped on this... here's what I'm trying to accomplish.

I have a Photo Gallery that I upload photos to and select from a category list that the photo is related to (gallery_category) using a list

Get options from database
Section Tablename: gallery_categories
Use this field for option values: name
Use this field for option labels: name.

I'd like to feature specific photos on the home page of my website, so I created a (feature_gallery_category) which pulls the same records from the:

Get options from database
Section Tablename: gallery_categories
Use this field for option values: name
Use this field for option labels: name.

In the Home Page section within the CMS I select the category associated with the photos I'd like to display on the home page of my website. I know I could hard code this, but I need it to be dynamic so as new Categories are added in the future, they become available in the drop down list. The code below doesn't work and I'm certain off track... can someone provide some guidance to get this feature working?

<?php if ($home_pageRecord['feature_gallery_category']==$galleryRecord['gallery_category']): ?>
<div class="photo">
<?php foreach ($galleryRecords as $record): ?>
        <?php foreach ($record['gallery_photo'] as $upload): ?>
<a href="<?php echo $upload['_link'] ?>" title="<?php echo $upload['info1'] ?> <?php echo $upload['info2'] ?>">
<img src="<?php echo $upload['thumbUrlPath'] ?>" alt="<?php echo $upload['info1'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" /></a>
<?php endforeach ?><?php endforeach ?>
<!-- /photo --></div>
<?php endif ?>

Hi Zick,

It looks like you're on the right path. I think you just need to modify your code so it looks like this:

  // load record from 'gallery'
  list($galleryFeaturedRecords, $galleryFeaturedMetaData) = getRecords(array(
    'tableName'   => 'gallery',
    //'where'       => '', // load first record
    'where'       => " gallery_category LIKE '%Visitors%' ",
    'where'       => "gallery_category LIKE '%".$home_pageRecord['feature_gallery_category:label']."%'",
    'loadUploads' => true,
    //'allowSearch' => true,
    'limit'       => '1',
  ));
  $galleryFeaturedRecord = @$galleryFeaturedRecords[0]; // get first record

So I've added apostrophes around the string, and added the percent signs on the inside of the string so that MySQL knows that it can look for this variable anywhere in the field.

Let me know if you have any questions.

Thanks!

Greg 

Greg Thomas







PHP Programmer - interactivetools.com