List of picture article. Problem with thumb

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

By mbareara - August 2, 2013

Hi to all and thank you in advance for your help.

I have a section with multiple article with 10 or more picture uploaded.

In the list i would have Title, Picture, and Summary. But i would have of course just ONE picture (better if i can choose it with dragOrder)

I have now this code.... but of course it give me alla the picture...

<?php foreach ($fotoRecords as $record): ?>

<!-- vid --> <div class="video_box_item">
<div class="video_box_thumb">
<a href="<?php echo $record['_link'] ?>"><?php foreach ($record['immagini'] as $upload): ?><img src="<?php echo $upload['urlPath'] ?>" width="120" height="90" border="0" alt="<?php echo $record['info1'] ?>" /><?php endforeach ?></a>
</div>
<div class="video_box_text">
<div class="video_box_title"><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></div>
<div class="video_box_desc"><?php echo $record['summary'] ?></div>
</div>
</div>
<!-- /vid -->
<?php endforeach ?>

Could you help me?

By gregThomas - August 2, 2013

Hi,

Glad you've solved the problem. Here is another way you could do this:

<a href="<?php echo $record['_link'] ?>">
  <?php  if($image = @$record['immagini'][0]): ?>
    <img src="<?php echo $image['urlPath'] ?>" width="120" height="90" border="0" alt="<?php echo $image['info1'] ?>" />
  <?php endif ?>
</a>

So if there is a one record in the immagini array we assign it to variable $image, then you can display the content from that image variable.

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com