Image from Multi record

10 posts by 2 authors in: Forums > CMS Builder
Last Post: April 17, 2018   (RSS)

I have got a multi record displaying text and images, on the list page I have got the records displaying with text and an image which is fine but I want to show the first image from the first record separately, so I have the list on the left with small images and text then I want the first image form the first record on the right, at the moment it is showing the image from the second record, not the first. What am I doing wrong?

Thank you but where do I put that code? This is the code I have to pull in the image:

<!-- STEP 2a: Display Uploads for field 'summary_image' (Paste this anywhere inside STEP2 to display uploads) -->
        <!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
        <?php foreach ($record['summary_image'] as $index => $upload): ?>
          <?php if ($index >= 1) { continue; } // limit uploads shown ?>

          <img src="<?php echo htmlencode($upload['urlPath']) ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo htmlencode($upload['info1']) ?>" />

        <?php endforeach ?>
      <!-- STEP2a: /Display Uploads -->

By leo - April 11, 2018 - edited: April 11, 2018

If you just want to get the first upload of the record, $record['summary_image'][0] is what you need instead of a foreach loop. If this code snippet is for displaying the rest images then the if statement should be if($index < 1).

Do you have a screenshot or example of what you want to accomplish so I can get a better understanding of the question?

Thanks,

Leo - PHP Programmer (in training)
interactivetools.com

Hi, this is still not working so I have reverted the code to what I had without your fix in place, I have attached the page code and the link to view the example is below, the image should be the main image from the top story not the bottom story as it is now.

http://77.68.95.152/~wwwgreatwalstead/latest-news.php

Attachments:

latest-news.php 14K

By leo - April 12, 2018 - edited: April 12, 2018

According to your file, the first record of $latest_newsRecords is $latest_newsRecords[0]. After finishing the first foreach loop your $record variable will contain the last element of $latest_newsRecords. So just use $latest_newsRecords[0]['single_image'][0] should give you the first upload of the first record in $latest_newsRecords.

Leo - PHP Programmer (in training)
interactivetools.com

Sorry I still cannot get this to work, I need only one image to show on the page, so ONLY the image from the first record in a different DIV.

By leo - April 16, 2018

Hi,

Did you try using $latest_newsRecords[0]['single_image'][0]? If so what is the error that you are having?

Leo - PHP Programmer (in training)
interactivetools.com

Yes I did, I don't get an error it just doesn't work. Is there anyway you can try it and send me the code, the trouble is I want the image to be in a different area as you can see from the code I sent.

By leo - April 17, 2018

Sure! You can send a support request to support@interactivetools.com with the ftp information and the file and we will take a closer look at the problem!

Leo - PHP Programmer (in training)
interactivetools.com