Categories and records grouped on same page

17 posts by 4 authors in: Forums > CMS Builder
Last Post: May 13, 2009   (RSS)

By ross - May 6, 2009

Hi Pete.

I'll see what I can do for you. Can you post a copy of the actual template file you are working with as well? Are both your sections using the same schema? If they aren't, post up a copy of your other schema file and we'll go from there.

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] Categories and records grouped on same page

By petejdg - May 6, 2009 - edited: May 6, 2009

Here is my template - I have a sample category header and record above my coding.

By ross - May 6, 2009

Hi Pete.

There isn't anything attached :). Could you try again?

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] Categories and records grouped on same page

By petejdg - May 6, 2009

Sorry, it is attached now!

Re: [ross] Categories and records grouped on same page

By petejdg - May 11, 2009

Ross,
did you happen to come up with anything yet? I have messed some more but am very stuck. Obviously I don't know much php.

pete

By ross - May 13, 2009

Hi Pete

Thanks for hanging on :).

I think you might actually be looking for something a little different than this thread is dealing with.

To me, it sounds like what you need is a list of all your staff but organized by category. To get something like that, try out this test code:

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


That will give you a heading for each category and then display the names of each person. You can add in more fields to display if you like or change the formatting. Basically though, the code is checking what the current category name is. If it's the same as the last one it displayed, then it just keeps going. If the current category is different from the previous one, it displays the category name.

What you'll need to do is make sure in your viewer code at the top of the page, you have

'orderBy' => 'category DESC',

You need to sort the list by the category.

Give this a shot and let me know how you make out. 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/