display one picture on listing from array

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

By mbodamer - February 7, 2013

hi,

  I am having a little bit of trouble and hope this is an easy one for you guys.  on my listing details page, it lists the 10 or so photos that a listings has along the right hand side in a column of thumbnails.  you click them to enlarge etc... works fine.  what I would like to do is place the first picture in the list centered on the listing and large size already... you cant click it or anything it would already be the width of the listing.  then the rest of them would be on the side as normal.

  if i HAVE to if it makes it alot easier, i can show the entire list of photos on the right as is now and simply add the first one as a large static image in the top center of the listing.  but ideally i would like the first one removed from the column and moved to the center larger.

hope im making sense.  

thanks

By gregThomas - February 8, 2013

Hi,

Is this on a detail page for a record? If so, you could display the first image in your image array using something like this:

<?php  
  // load records from 'blog'
  list($blogRecords, $blogMetaData) = getRecords(array(
    'tableName'   => 'blog',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

  showme($blogRecords);

  $blog = $blogRecords[0];

?>
 
  <!-- display the first image in your array -->
  <?php if($image = @$blog['uploads'][0]): ?>
    <div>
      <img src="<?php echo $image['urlPath']; ?>" alt="<?php echo $image['info1']; ?>" />
    </div>
  <?php endif; ?>

This is just some example code, so you'll need to modify it to work with the variables you are using. I've left in my getRecords function so you can see how I've set it up. 

So if we can set the first images in the arrays data to the variable $image, then we we display the image. 

If you attach your code to a post, I could give you a more specific example if you need.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com