
Donna
Staff

Sep 19, 2008, 2:35 PM
Post #2 of 5
(2587 views)
Shortcut
|
|
Re: [Deborah] sorting by date - for blog archives
[In reply to]
|
Can't Post
|
|
Hi Deborah, Thanks for your post. :) This isn't specifically a feature of CMS Builder so it's a little beyond what our support can normally handle... but we wanted to give it a try anyway so I think we've come up with some custom code that should make this work. Here's the code I used:
<?php require_once "C:/wamp/www/cmsAdmin/lib/viewer_functions.php"; ?> <?php // get list of unique months and years with articles $query = "SELECT DATE_FORMAT(date, '%M %Y') as dateAndYear, YEAR(date) as year, MONTH(date) as month FROM cms_blog GROUP BY dateAndYear ORDER BY date"; $result = mysql_query($query) or die("MySQL Error: ". htmlspecialchars(mysql_error()) . "\n"); while ($record = mysql_fetch_assoc($result)): ?> <a href="blogList.php?date_year=<?php echo $record['year'] ?>&date_month=<?php echo $record['month'] ?>"><?php echo $record['dateAndYear']; ?></a><br/> <?php endwhile ?> Note: You'll want to replace the first "require_once" line with the correct path from your code generator, and also replace the table name (in my example, cms_blog) with the correct name, and the filename (where I've got blogList.php) with your list filename. Put this in wherever you want your archive list to be, and that should do it. :) Donna -- support@interactivetools.com
|