Blogs Archives

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 25, 2011   (RSS)

By design9 - May 25, 2011

Hello, I am using the following code in my blog menu to show a list of the available blog archives by month and year so when you click on the link, it takes you to the blog archives for only that month.

<?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_blogs GROUP BY dateAndYear ORDER BY date DESC";
$result = mysql_query($query) or die("MySQL Error: ". htmlspecialchars(mysql_error()) . "\n");
while ($record = mysql_fetch_assoc($result)):
?>
<ul class="listnav">
<li><a href="http://www.charlotteparent.com/community/blogsnew/archives.php?date_year=<?php echo $record['year'] ?>&date_month=<?php echo $record['month'] ?>"class="blinks"><?php echo $record['dateAndYear']; ?></a></li>
</ul>
<?php endwhile ?>

Here is an example of the page with menu in right sidebar: http://www.charlotteparent.com/community/blogsnew/blogs.php?category=culture%20kid%20reviews

The issue that I am having is figuring out how to list the month and year once at the top of the page next to the word Archives. So, for example if the user clicks on April 2011 and it takes them to the April blog Archives, I want it to say at the top of the page "Archives - April 2011" where it now says Archives in the large green text. I have tried many different options to pull in the month and year but it doesn't work because of this coding I have in place. Can you tell me how I can show the month/year so users can see the archive month at the top of the page?

Thanks!

April

Re: [Jason] Blogs Archives

By design9 - May 25, 2011

Thanks Jason!

That works perfectly! :)

April