Grouping listings by month with header
            4 posts by 3 authors in: Forums > CMS Builder
Last Post: November 3, 2008   (RSS)          
          I have a list of events that are pulled from a multi record editor and displayed on a listings page, sorted by date.
http://98.131.167.226/happenings.php
I’d like to be able to group the listings by month (in ascending order) with a “month” heading (probably an image) at the top of each month’s group.
If there are no listings for a particular month then no heading would be shown.
Anyone have an elegant solution?
Sorry, I just can’t seem to get my head around this one.
Thanks
Jerry Kornbluth
                          
        http://98.131.167.226/happenings.php
I’d like to be able to group the listings by month (in ascending order) with a “month” heading (probably an image) at the top of each month’s group.
If there are no listings for a particular month then no heading would be shown.
Anyone have an elegant solution?
Sorry, I just can’t seem to get my head around this one.
Thanks
Jerry Kornbluth
      The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
                    Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Grouping listings by month with header
By Kenny - October 26, 2008 - edited: October 26, 2008
           Here's one built in a table you could use:
You'll need to replace my code with your code -
Hope that helps -
Kenny
                                        
        You'll need to replace my code with your code -
<table>
<?php
    $lastCategory = "";
    foreach ($eventRecords as $record):
	  $showHeader = false;
      if ($record['month'] != $lastCategory) {
	    $lastCategory = $record['month'];
		$showHeader = true;
	  }
   ?>
	<?php if ($showHeader): ?>
		<tr>
			<td><?php echo $record['month'] ?></td>
		</tr>
        <?php endif ?>
		<tr>
			<td><?php echo $record['title'] ?></td>
		</tr>
		<tr>
			<td><?php echo $record['content'] ?></td>
		</tr>
     <?php endforeach; ?>
</table>Hope that helps -
Kenny
Re: [gkornbluth] Grouping listings by month with header
By InHouse - November 3, 2008
          There's another link here which might be helpful in these types of cases:
http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/gforum.cgi?post=61462;search_string=sub%20grouping;t=search_engine#61462
Hope it helps.
J.
                                        
        http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/gforum.cgi?post=61462;search_string=sub%20grouping;t=search_engine#61462
Hope it helps.
J.
Re: [Judis] Grouping listings by month with header
          Thanks for finding this. 
I'll give it a try along with Kenny's ideas and let you know how it works out.
Jerry
                          
        I'll give it a try along with Kenny's ideas and let you know how it works out.
Jerry
      The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
                    Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php