5 posts by 4 authors in: Forums > CMS Builder
Last Post: February 2, 2012   (RSS)

I would like to use CMS Builder to create a blog, but the pre-configured blog Section Editor does not include an archiving feature.

I would like all blog posts for the past 30 days to appear on the active blog page. Any posts dated 31 days or older, to be archived and categorized by month. For example, I'd have in the left or right column of the page:

July 2008 (links to all posts for this month)
June 2008 (links to all posts for this month)
May 2008 (links to all posts for this month)

I can figure out how to filter the active blog page to show only the past 30 days, but I don't know how to set up the archives as shown above. It seems that this link generation could be automated using some PHP date code, but I'm not familiar enough with PHP to know how to do this. Can anyone provide an example?

Re: [Deborah] sorting by date - for blog archives

By Donna - September 19, 2008

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

// 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. :)


Re: [Donna] sorting by date - for blog archives


The code you provided does exactly what I was looking for! Many, many thanks to you and your team for going above and beyond to come up with this. I'm sure it will be helpful to others here in the forum, too. I now feel confident in offering CMS Builder as a solution for site blogs. (And for me personally, CMS Builder is far easier to style to match a site design than trying to customize blog software templates.)

Thanks once again for your superior customer support!


Re: [Donna] sorting by date - for blog archives

By sidcam - September 14, 2010 - edited: September 14, 2010




That was about the only feature of my old Wordpress blog I hadn't figured out how to mimic.