Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hi,

Is there an easy way to produce archives for a blog in the format:

2012
- December
- November
- October
- etc

2011
- December
- November
- October
- etc


Thanks
Daz
Hi Daz,

Welcome to our forums :)

The cms:archives tag has a 'type' parameter that can be set to 'yearly', 'monthly' or 'daily' to output the relevant listing.
In addition, it also supports the 'start_on' and 'stop_before' parameter to set the period of the archive.

We can use the parameters mentioned above to output the kind of listing you mentioned.
We'll use the 'archives' tag twice -
Once for getting the 'yearly' listing and then within each of the yearly period we'll call the 'archives' tag again - this time to get a monthly listing that is constrained to the enclosing year.

Here is a sample code -
Code: Select all
<ul>
<cms:archives masterpage='blog.php' type='yearly'>
   <li>
      <a href="<cms:show k_archive_link />"><cms:date k_archive_date format='Y' /></a>
      <ul>
         <cms:archives masterpage='blog.php' type='monthly' start_on=k_archive_date stop_before=k_next_archive_date>
            <li><a href="<cms:show k_archive_link />">- <cms:date k_archive_date format='F'/></a></li>
         </cms:archives>
      </ul>
   </li>
</cms:archives>
</ul>

Output:
Code: Select all
    *   2011
          o - December
          o - October
          o - August
          o - June
          o - May
          o - March
    * 2010
          o - November
          o - October
          o - August
          o - July
          o - June

Hope this helps.
Do let me know.

Thanks.
Apologies for the delayed response, the project got put on hold for a couple of weeks. That solution works perfectly, thanks!
3 posts Page 1 of 1
cron