Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
List page categorized by field

 

 


steve_e
User

Mar 29, 2008, 2:55 AM

Post #1 of 3 (210 views)
Shortcut
List page categorized by field Can't Post

I'd like to have the records of the list (or index?) page appear sorted by a field from the record.

So, for example, if the section gave details of cats, with age, name, address and breed as fields, I would like to list all Manx cats, followed by all tabby cats or whatever.

But I'd only like the field label (eg 'Manx') to appear once, as a heading. How would I set the logic for that? I've tried a couple of different 'for each' and 'if' variations but my coding skills are pretty minimal...


Dave
Staff / Moderator


Mar 29, 2008, 4:44 AM

Post #2 of 3 (206 views)
Shortcut
Re: [steve_e] List page categorized by field [In reply to] Can't Post

Hi Steve,

Sort by breed first, then whatever field you want to sort on next. Then... Add this bit of code to your list records block:


Code
<?php foreach ($listRows as $record): ?>  
...

<?php if ($record['breed'] != @$lastBreed): ?>
<h1><?php echo $record['breed'] ?></h1>
<?php $lastBreed = $record['breed']; endif ?>
...
<?php endforeach ?>



Basically, we just keep a copy of the breed from the last record in $lastBreed, and if it changes we show a heading.

Hope that helps! Let me know if you need any more assistance with that.

Dave Edis - Senior Developer
interactivetools.com


steve_e
User

Mar 29, 2008, 7:45 AM

Post #3 of 3 (204 views)
Shortcut
Re: [Dave] List page categorized by field [In reply to] Can't Post

Hi Dave -
Excellent, thanks very much!
Best wishes,
Steve.

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4