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 ?>

By Mikey - March 23, 2013

So I've been messing around with 'where' trying to get this to work. It works just as I need it to if I hard code %Visitors% into the ('where'   => " gallery_category LIKE '%Visitors%' ",) as seen in bold black.

But I need to make this dynamic, so that I can choose one category from a list various category options and have the the were statement update according to category selected. So if in the "Home Page" section of my site, I change my category from "Visitors" to "Guest" then the latest photo associated with "Guest" uploaded to the photo gallery will be displayed on the Home Page of my website. Something like what can bee seen in bold red.

Anyone have any suggestions to make this dynamic in the WHERE clause?

  // 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