Page Heading and Image Display

9 posts by 2 authors in: Forums > CMS Builder
Last Post: July 14, 2009   (RSS)

By KCMedia - July 12, 2009

Hi

I have this page that works ok but now the client wants a couple of small changes and i cant work out how to get them to work.

1. I have a sections area for each product in a drop down list and i have it showing

<h3><?php foreach ($productsRecords as $record): ?><?php echo $record['section'] ?>
<?php endforeach; ?>
<?php if (!$productsRecords): ?><br/>
<?php endif ?></h3>

But the problem it that if there is only one product in the section then it will show the section title only once but when there are more then it will show as many times as there is products so i want to limit the amount of times that the section title showup to only once.

2. With the products i want to limit on this page to only the first 3 images i can put the <?php break ?> but this will only show the first image i want to show 3.

I have included a copy of the whole php file to see.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz
Attachments:

products.php 11K

Re: [kcmedia] Page Heading and Image Display

By ross - July 13, 2009

Hi there.

Thanks for posting!

Let's go over this one point at a time starting with the category headers. This is a fairly common thing so there is already some code you can try using. Check out this post:


http://www.interactivetools.com/forum/gforum.cgi?post=71704#71704


The example there is grouping staff members but the concept is exactly the same. Make sure you order this section by the category field and then try out that code. You'll need to make sure you swap in the proper variables for $our_staffRecords and $record['category']

Let me know how you make out with that. I think for now, just post back to this thread if you wanted to go over any part of that in more detail.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [kcmedia] Page Heading and Image Display

By KCMedia - July 13, 2009

Hi Ross

I found how to fix the issue i had to change the code to look like this

<?php $lastCategory = ''; ?>
<?php foreach ($productsRecords as $record): ?>
<?php if ($lastCategory != $record['section']): ?>
<?php echo $record['section'] ?>
<?php endif; ?>
<?php $lastCategory = $record['section']; ?>
<?php endforeach; ?>

if i did it like this i would multipule lines of section headers

<?php $lastCategory = ''; ?>
<?php foreach ($productsRecords as $record): ?>
<?php if ($lastCategory != $record['category']): ?>
<h1><?php echo $record['section'] ?></h1>
<?php endif; ?>
<?php echo $record['section'] ?><br/>
<?php $lastCategory = $record['section']; ?>
<?php endforeach; ?>


so now it looks all ok now i just need to get that image issue fixed.

thanks and await your reply.

Craig
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Page Heading and Image Display

By ross - July 14, 2009

Hi Craig

That's perfect :).

I hadn't forgotten your other question. It's always better to look at things one at a time so I was just making sure we got the category stuff taken care of first.

Now that it's done we can move onto the images. Can you post me a copy of the default code for your images. You can get that from your code generator. It will be a foreach loop (within the main foreachloop).

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Page Heading and Image Display

By KCMedia - July 14, 2009 - edited: July 14, 2009

Hi Ross

here is the code


<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Products - List Page Viewer</h1>
<?php foreach ($productsRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Sort Order: <?php echo $record['sort_order'] ?><br/>
Section: <?php echo $record['section'] ?><br/>
Name: <?php echo $record['name'] ?><br/>
Product ID: <?php echo $record['product_id_sku'] ?><br/>
Description: <?php echo $record['description'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>


<!-- STEP 2a: Display Uploads for field 'images' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['images'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

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


<hr/>
<?php endforeach; ?>

<?php if (!$productsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

</body>
</html>

I hope this is right as i am running out of time the client is pushing me about this now.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Page Heading and Image Display

By ross - July 14, 2009

Hi there.

Thanks!

What you'll want to do is add in

<?php $counter = 0; ?>

right before the start of your image foreach loop. Then, right before the endforeach for the images, add in

<?php if ($counter++ == 2) {break;} ?>

You'll have something like this

<?php $counter = 0; ?>
<!-- STEP 2a: Display Uploads for field 'images' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['images'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php if ($counter++ == 2) {break;} ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->


Give it a shot and let me know how you make out :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Page Heading and Image Display

By KCMedia - July 14, 2009

Hi Ross

100% great now all is done i can hand over the site to the client and everything if working great now and site looks perfect.

thanks

Craig
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Page Heading and Image Display

By ross - July 14, 2009

Great! Let me know how it goes. If there is anything else we can help with, post away :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/