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

Dave,

I really love CMS. It allows me to get my clients very happy, and i'm happy to with that!

I want to make you an answer regarding this item.

I have 2 sections in CMS called "Featured Homes" and "Meet our Team"

I want to put a field under Detailed Property to show which agent of "our team" is seeling that home.

This is the url:

http://www.utahreoexperts.com/featured-homes/detail/?SELLER-MOTIVATED-TOWNHOME-6

I know how to create a pull list field called "Agent" and get it from Get options from database, under "Featured Homes" section.

But Im stuck to get that record and echo into Detailed Property.

What should i do?

Thank you Dave, Juan.

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