Divide a single list into multiple groups

10 posts by 4 authors in: Forums > CMS Builder
Last Post: November 18, 2008   (RSS)

By zip222 - August 25, 2008

I have a list of donors, and each belongs to a category. I would like to divide up the list into different sections based on the various categories.
- corporate, individuals, legacy, etc...

Is there a way to do this using only one section?

Re: [jdancisin] Divide a single list into multiple groups

By Dave - August 25, 2008

Yes, here's the steps:

1) Create a mockup of how you want it to look.

2) Create a pulldown field for category (corporate, individuals, legacy, etc) and make that a required field.

3) Sort by category first, then whatever other fields you want to sort by.

4) Then display the category name once above each group like this:

<?php if ($record['category'] != @$lastCategory): ?>
<?php $lastCategory = $record['category']; ?>

<h1><?php echo $record['category'] ?></h2>

<?php endif ?>


Hope that helps, let me know if you run into any problems with that.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Divide a single list into multiple groups

By zip222 - August 25, 2008

Ok... something is happening, but not I am not sure what:

<ul>
<?php foreach ($donor_listRecords as $record): ?>
<?php if ($record['type'] != @$lastCategory): ?>
<?php $lastCategory = $record['type']; ?>
<li><?php echo $record['name'] ?> (<?php echo $record['type'] ?>)</li>
<?php endif ?>
<?php endforeach; ?>
</ul>

Re: [jdancisin] Divide a single list into multiple groups

By zip222 - August 25, 2008

You know, I don't think I explained myself very well in my original post. Let me try again:

I have created a section that includes a list of donors. For each donor record, I have two fields: 'name' and 'type'. The 'type' field is a dropdown menu that includes four different options.

On the public page, I want to display four different lists of donors - one for each "type". This is what I need help with.

Re: [jdancisin] Divide a single list into multiple groups

By Dave - August 25, 2008

Ok, the first step is to create a mockup of how you want the page to look. Are you able to post an url of the mockup page?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Divide a single list into multiple groups

By zip222 - August 25, 2008

I just figured it out. Thanks.

Re: [jdancisin] Divide a single list into multiple groups

By Dave - August 25, 2008

Great, glad to hear it's working! :) Let us know if you need anything else.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Divide a single list into multiple groups

By willbegood - November 13, 2008

Just what i was looking for. It takes me 1 minute to find the solution on the forum.
You guys are great!!!!

Re: [jposwald] Divide a single list into multiple groups

By Dave - November 18, 2008

Hi Juan,

The first step is to get the record number of the agent.

Create a pulldown in homes that loads it's values from "team" with num for the value and name for the "label".

Next, try displaying that agent number on the listing page.

Then once that is working you can load that agents record like this:

list($teamRecords, $teamMetaData) = getRecords(array(
'tableName' => 'team',
'where' => "num = '$teamMemberNum' ",
'allowSearch' => false,
));
$agent = @$teamRecords[0]; // get first record


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com