List page categorized by field

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 29, 2008   (RSS)

Re: [steve_e] List page categorized by field

By Dave - March 29, 2008

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:

<?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

Re: [Dave] List page categorized by field

By steve_e - March 29, 2008

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