EE: Yearly Archives plugin
Yearly Archives: een ExpressionEngine plugin. Start Engelse modus…
With this plugin, you can easily set up yearly archives like this (in Dutch, but you’ll get the idea) in an efficient way. You could consider it an alternative to the Archive Month Links Tag. Tested with EE version 1.4.1 build 20060217 and onwards.
→ Download the Yearly Archives plugin version 1.11
Parameters
weblog="blog|news"status="not closed"show_expired="yes"show_future_entries="yes"sort="asc"monthsort="desc"start_month="1"(defaults to the month of the oldest entry)end_month="12"(defaults to the month of the newest entry)start_year="2000"(defaults to the year of the oldest entry)end_year="2010"(defaults to the year of the newest entry)
Tag pairs
{months backspace="1"}{/months}
Single tags
{year}{year_short}{month_count}{leap_year}{entries_in_year}{month}*{month_num}*{month_short}*{month_num_short}*{num_entries}*
Note: Tags marked with * are available in between the {months} tag pair only.
Example
<ul class="yearly_archives">
{exp:yearly_archives weblog="blog" start_month="1" status="not closed" sort="desc"}
{if entries_in_year > 0}
<li>
{if leap_year == 1}<em>{year}</em>{if:else}{year}{/if}
<ul>{months}
<li>
{if num_entries > 0}
<a href="{path=blog/archive}{year}/{month_num}/" title="{num_entries} entries in {month} {year}">{month_short}</a>
{if:else}
{month_short}
{/if}
</li>{/months}
</ul>
</li>
{/if}
{/exp:yearly_archives}
</ul>
New in version 1.1 - 2006.04.28
- Added parameter
monthsortto change the order of months in a year. Defaults toasc
New in version 1.11 - 2007.04.09
- Fixed a bug where
show_expiredandshow_future_entrieswere swapped
- 3 maart 2006, 15:23
- Add-Ons, ExpressionEngine
- 55 comments

any demo?
Sure, like I pointed out at the beginning of this post: these archives work with this plugin (and some ajax ^_^). Chris Ruzin uses it too.
I need a listing of yearly archives for events. The page should list upcoming events from the current year ONWARDS, and on the side, should provide links to past from previous years. How do I do this?
With EE I had to manually hardcode the current year to get the the page to work.
Can the plugin avoid the hard-coding?
See
http://www.straitsknowledge.com/events/
Maish, you could probably work around hard-coding the current year by allowing php in your template and adding some code. Take a look at these two threads over at the pMachine forums.
How would you get both the years and months to be descending? Playing around with start_month and sort results in not all entries being displayed. Using your default set-up shows all results but with the months going from Jan - Dec instead of Dec - Jan (ie newest first).
John, version 1.1 allows for this functionality.
I must’ve just missed this by a few hours did I?
Actually, I added this to the plugin ’cause it couldn’t do what you asked. I think more people will benifit from this. :)
Hello Low,
I love your archive plugin. One cient would like to display their archives like this:
2005
2004
2003
…
the user clicks a year to display a list of all articles from that year in date order. is this possible with your plugin?
thanks!
David, you can create the list of years with this plugin. They could link to another template where you set up a
{exp:weblog:entries}tag and have that display entries per year. This plugin doesn’t create lists of entries, just lists of months and years.Sorry for posting in an old topic, but I just wanted to say thank you for this fantastic plugin. You should try to get this into the core of EE 2.0!
I am not able to show future entries using this plugin - though I am adding in
show_future_entries=”yes” - is there any further attributes I should be using to make it work correctly?
Thanks
Joel, it would appear you’ve discovered a tiny bug! I’ve switched
show_future_entriesandshow_expiredaround by mistake. I’ll fix this later on. For now, you can useshow_expired="yes"to achieve the desired result.Excellent! This almost drove me crazy today trying to track down where I had gone wrong, thanks very much for replying so quickly
Just one thing - how (if possible) can i restrict the listings to the current year only? I am showing an event scheduler and it needs to be restricted to just showing 12 months of entries? Thanks again
Joel, you should probably enable php in your template for that, explained here, and use
$year = $LOC->decode_date("%Y", $LOC->now);to retrieve the current year. You can then usestart_year="<?=$year?>"andend_year="<?=$year?>"to show only the current year.Ha! Very good - yes of course, that would do the job nicely; thanks again!
Joel, the bug has been fixed in version 1.11.
What I would like to to have is just a list like this:
*2007
-April
-March
-February
-January
2006
2005
2004
When someone click on a month, the monthly posting should be shown.
When someclick of a year, this year should expand (or collaps).
Is this possible to with your plugin????
Would be very nice!!!
Yes Erwin, that’s possible with this plugin. You’ll need to add some JavaScript to toggle the display of the list of months from block to none and vice versa. You can keep the markup almost exactly the same as in the example, only add a link or a span around the year and
ids to the nesteduls so you’re able to target them with JS.Great! Tx for your fast reply.
Just one question: do you have an example website where I copy the code from (I am not that a Java-guru ;) )
Erwin, a Google search for “toggle display javascript\” will get you going in the right direction.
Hi Low:
I ran into a recent problem with this plugin, I posted my question at the EE support forums, would it be best to resubmit here?
Thank you for producing such a useful plugin!
Feature Request: {switch} tag
Hi Low,
I really love your ajax archives, however, I do not seem to be able to figure out how to do it. Could you provide some help?
Is it possible to combine the ajax date archives with a ajax category archive: Depending on what one clicks on the archive list changes. I was planning on doing this own my own site since some time… (If I don’t make sense could you send me an email, maybe we could tackle this together and create a follow-up plugin…)
Squawk, have you seen my article on Ajax archives? Does that help?
My site has multiple sections, I’m having trouble linking to some sort of a page that will display all stories from that month in all of the sections, instead of just one.
Just the “{month_short}”
How can I specify multiple blogs/sections here?
{month_short}
Hi, Can this handle category parameter?
Display a weblog and a specific category only?
Thanks
Paul, there’s no category parameter support at the moment. Sorry…
Hi,
I from this thread on EE where someone managed to implement it but I am not sure where to place the code.
perhaps you can take a look and enlighted me.
Cheers, Paul
Post below:
————————————-
I’ve managed to find a workable solution for me. I’ve changed A few line of code in yearly archive.
Added:
$category = $TMPL->fetch_param(’category’) ? $TMPL->fetch_param(’category’) : ”;
$sql_category = $FNS->sql_andor_string($category, ‘cat_id’);
and changed SQL query to include:
INNER JOIN
exp_category_posts p
ON
t.entry_id = p.entry_id
This adds parameter category to {exp:yearly_archives /}
————————————-
Hi, Thanks for the great plugin. One thing I noticed though was that it doesn’t seem to work for entries that are on the 1st of any month. Is there something special I need to do to enable this? Has anyone else had this problem?
I’m using the following code:
{exp:yearly_archives weblog=”article” start_month=”1″ status=”not closed” sort=”desc”}
{months}
{if num_entries > 0}
…code here…
{/if}
{/months}
{/exp:yearly_archives}
It’s a big shame there’s no category support at the moment. I use the Category name in the URL so even the hack above doesn’t help me out.
It’s a shame as I really just need the {entries_in_year} single tag to for a count comparison in order to close a table of entries where I had a new table for each year.
@Mel: I haven’t seen that issue before. Can you point me to a working example?
@Steven: I’ll take category support into account for an upcoming version, if I ever get round to it. And by the looks of it, you shouldn’t be using this plugin for what you need, anyway. Some other custom plugin would be more efficient…
@Low If only someone would find a solution for me on the forums!
Hi Steven,
Do you know where to place the code I posted above to get it to work?
Paul, if you must, then here you go:
Add this code after line #41:
$category = $TMPL->fetch_param('category') ? $TMPL->fetch_param('category') : '';Add this code after line #55:
$sql_category = $FNS->sql_andor_string($category, 'p.cat_id');Add this code after line #68 (before
WHERE 1):INNER JOIN exp_category_posts p ON t.entry_id = p.entry_idAdd this code after line #72 (before
GROUP BY):$sql_categoryHi Low, thanks but it doesnt seems to work.
Do I use it like:
weblog=”blog” category-id=”2″
for example
Paul, try
category="2"instead ofcategory-id.Thanks a lot Low! :-)
Got it working.
Sorry if I have been a pain on this subject!
Paul
This may be two unrelated problems:
1) My most current month doesn’t appear until I have posted 2 entries
2) The {num_entries} count for a month is off by one ( shows 0 when there is actually 1 )
Much thanks
Scratch that. Here is description of the real bug:
I posted an entry at 2007-12-20 03:00 AM - and the plugin didn’t recognize it
I moved the date back hourly and at 2007-12-19 07:36 PM is when it recognized the entry as being there
Mysteries!
@Mike: strange indeed. I’ll look into it as soon as I get the chance.
Hi,
i m usign this code
============
{exp:yearly_archives weblog=”f1news” start_month=”1″ status=”not closed” sort=”desc” }
<li>
{if entries_in_year > 0}
{if leap_year == 1}{year}{if:else}{year}{/if}
{months}
{if num_entries > 0}
{month_short}
{if:else}
{month_short}
{/if}
{/months}
{/if}
</li>
{/exp:yearly_archives}
</ul>
=============
What i want is i want to print the months only related to current year & links to rest of the year.
How did you do your archive. I would really like to have something like that on mye site.
And is it possible to change te location of the news depending on what category the news is. I it is a eview i would like it to go to an other place than the regular news.
Thank you for this plugin, I love it and I have used it in a couple of sites.
Handige tool, als ik het maar werkende kreeg.
@Edwin: I’d point you in the right direction, if only I’d know what your problem is.
Hi low, great plugin!
I’ve been running into a problem with selecting “end_year” however. I’m using some php to get first year and last year as I want to do exactly what #19 does.
I want current year to default to on and the only way I can think to do this is by having 2 instances of the plugin. The first only showing current year with start_year=”<?php echo $year; ?>” and the second instance end_year=”<?php echo $last_year; ?>”.
The problem is that the second instance, what is supposed to be last year, is only displaying the number of months of the CURRENT year. So, for example, 2007 months end in April. I thought it might be my php so I hard coded end_year=”2007″ and got the same results.
Any help is much appreciated :)
To clarify a little bit:
Even with only one instance of the plugin, if I say end_year=”2007″ it shows only the number of months for 2008 yet the URL’s display correctly (ie:2007).
If I say end_year=”2008″ all months and URLs are displayed correctly, but unfortunately this won’t work as we want to be able to target 2008 separately.
Hi Joey. I’m not entirely sure what you’re trying to accomplish, but if you’re after something like #19, then you’ll need some JavaScript to show/hide the list of months per year. Here’s a snippet of code I used, php on input:
Now you can use the classes
showandhiddento display or hide the list of months, and you can use the links withclass="toggle"to switch between views.You can see it something similar right here (bottom left), although that shows 2 years by default if the active month of the current year is April or less.
Hi again Low!
Sorry, I should have been more clear. The javascript toggling and all that is functioning. My problem is a basic one and I’ll try and explain it better.
When I set the plugin to end_year=”2007″, it doesn’t show all the months in 2007. Instead it only shows Jan, Feb, March and April, the same number of months that are in 2008. The URL’s all show the correct year but the number of months is incorrect. end_year=”2007″ should show all months Jan-Dec. However, if I set end year 2008 it shows every year correctly.
Hope my problem makes more sense now. Again, appreciate your help and love the plugin.
Hi Joey. I was able to reproduce your problem. I think you can solve it by explicitly defining the end_month parameter:
end_month="12".Let me know if that works out for you.
AH! So simple :) Thanks so much, really appreciate it. I hope ya a beer!
…”owe” that is, not “hope”.