EE: Yearly Archives plugin

Yearly Archives: a ExpressionEngine plugin. This post now provides a place for support for the Low Yearly Archives plugin.

Download and docs for Low Yearly Archives can be found in the Software section

March 3rd 2006 | Add-Ons, ExpressionEngine | 128 comments

Comments

  1. 1 yoman March 9th 2006, 17:19

    any demo?

  2. 2 Low March 9th 2006, 17:56

    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.

  3. 3 maish April 16th 2006, 03:55

    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/

  4. 4 Low April 18th 2006, 10:35

    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.

  5. 5 John April 28th 2006, 05:40

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

  6. 6 Low April 28th 2006, 10:15

    John, version 1.1 allows for this functionality.

  7. 7 John April 28th 2006, 14:36

    I must’ve just missed this by a few hours did I?

  8. 8 Low April 28th 2006, 16:01

    Actually, I added this to the plugin ’cause it couldn’t do what you asked. I think more people will benifit from this. :)

  9. 9 David October 5th 2006, 17:17

    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!

  10. 10 Low October 5th 2006, 18:12

    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.

  11. 11 Chris January 31st 2007, 12:34

    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!

  12. 12 joel April 4th 2007, 16:01

    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

  13. 13 Low April 4th 2007, 16:25

    Joel, it would appear you’ve discovered a tiny bug! I’ve switched show_future_entries and show_expired around by mistake. I’ll fix this later on. For now, you can use show_expired="yes" to achieve the desired result.

  14. 14 joel April 4th 2007, 21:30

    Excellent! This almost drove me crazy today trying to track down where I had gone wrong, thanks very much for replying so quickly

  15. 15 joel April 4th 2007, 23:02

    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

  16. 16 Low April 5th 2007, 10:31

    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 use start_year="<?=$year?>" and end_year="<?=$year?>" to show only the current year.

  17. 17 joel April 5th 2007, 22:06

    Ha! Very good - yes of course, that would do the job nicely; thanks again!

  18. 18 Low April 9th 2007, 21:47

    Joel, the bug has been fixed in version 1.11.

  19. 19 Erwin van Lun April 21st 2007, 17:40

    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!!!

  20. 20 Low April 21st 2007, 18:26

    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 nested uls so you’re able to target them with JS.

  21. 21 Erwin van Lun April 21st 2007, 19:13

    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 ;) )

  22. 22 Low April 23rd 2007, 10:12

    Erwin, a Google search for “toggle display javascript” will get you going in the right direction.

  23. 23 Darrin May 4th 2007, 02:21

    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!

  24. 24 Martin Hipp June 24th 2007, 10:28

    Feature Request: {switch} tag

  25. 25 Squawk August 26th 2007, 00:42

    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…)

  26. 26 Low August 26th 2007, 12:22

    Squawk, have you seen my article on Ajax archives? Does that help?

  27. 27 sp1024 September 22nd 2007, 23:18

    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?

  28. 28 sp1024 September 22nd 2007, 23:22
  29. 29 Paul November 3rd 2007, 19:32

    Hi, Can this handle category parameter?
    Display a weblog and a specific category only?

    Thanks

  30. 30 Low November 3rd 2007, 21:08

    Paul, there’s no category parameter support at the moment. Sorry…

  31. 31 Paul November 4th 2007, 21:10

    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 /}

    ————————————-

  32. 32 Mel November 22nd 2007, 23:50

    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}

  33. 33 Steven Hambleton November 25th 2007, 18:26

    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.

  34. 34 Low November 26th 2007, 18:48

    @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…

  35. 35 Steven Hambleton November 26th 2007, 23:59

    @Low If only someone would find a solution for me on the forums!

  36. 36 Paul November 27th 2007, 13:42

    Hi Steven,
    Do you know where to place the code I posted above to get it to work?

  37. 37 Low November 27th 2007, 14:31

    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_id

    Add this code after line #72 (before GROUP BY):
    $sql_category

  38. 38 Paul November 30th 2007, 17:18

    Hi Low, thanks but it doesnt seems to work.

    Do I use it like:

    weblog=”blog” category-id=”2″

    for example

  39. 39 Low December 1st 2007, 12:59

    Paul, try category="2" instead of category-id.

  40. 40 Paul December 1st 2007, 14:44

    Thanks a lot Low! :-)
    Got it working.
    Sorry if I have been a pain on this subject!

    Paul

  41. 41 mike December 20th 2007, 10:43

    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

  42. 42 Mike December 20th 2007, 10:59

    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!

  43. 43 Low December 20th 2007, 11:23

    @Mike: strange indeed. I’ll look into it as soon as I get the chance.

  44. 44 Vikas January 11th 2008, 14:26

    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.

  45. 45 kankuro January 25th 2008, 15:11

    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.

  46. 46 Nelly February 15th 2008, 03:58

    Thank you for this plugin, I love it and I have used it in a couple of sites.

  47. 47 Edwin February 25th 2008, 20:41

    Handige tool, als ik het maar werkende kreeg.

  48. 48 Low February 25th 2008, 23:27

    @Edwin: I’d point you in the right direction, if only I’d know what your problem is.

  49. 49 joey April 14th 2008, 18:25

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

  50. 50 joey April 14th 2008, 18:35

    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.

  51. 51 Low April 15th 2008, 09:23

    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:

    <?php
    $thisyear = date("Y",time());
    $thismonth = date("m",time());
    ?>
    <ul id="yearly_archives">{exp:yearly_archives weblog="blog" start_month="1" start_year="2005" sort="desc"}
    {if entries_in_year > 0}
    <li><a href="#year{year}" class="toggle">{year}</a>
    <ul id="year{year}" class="{if year == "<?=$thisyear?>"}show{if:else}hidden{/if}">
    {months}
    <li>{if num_entries > 0}<a href="{path=blog/archives/}{year}/{month_num}/">{month}</a>{if:else}{month}{/if}</li>
    {/months}
    </ul>
    </li>
    {/if}{/exp:yearly_archives}
    </ul>
    </pre>

    Now you can use the classes show and hidden to display or hide the list of months, and you can use the links with class="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.

  52. 52 joey April 15th 2008, 22:34

    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.

  53. 53 Low April 15th 2008, 23:18

    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.

  54. 54 joey April 16th 2008, 00:08

    AH! So simple :) Thanks so much, really appreciate it. I hope ya a beer!

  55. 55 joey April 16th 2008, 00:08

    …”owe” that is, not “hope”.

  56. 56 Jeff Adams May 28th 2008, 22:59

    I’m using your plugin to show a list of just the years with entries and I want to display the number of entries next to the year. From what I can tell {num_entries} only works with month listings. Is what I want to do currently possible?

  57. 57 Low June 3rd 2008, 11:59

    Hi Jeff, you could probably use the variable {entries_in_year} for this.

  58. 58 Jeff Adams June 3rd 2008, 18:43

    Ah excellent, that worked perfectly. I didn’t realize that variable existed. I didn’t see it in the usage info.

  59. 59 Joshua Hynes June 4th 2008, 20:19

    One quick question about this plugin:
    Is there any way to show all months in a year even if there aren’t any postings in that month. Just show the month number sans archive link? A good example of this can be found here (see footer for example).

    Thanks.

  60. 60 Low June 4th 2008, 23:43

    Hi Joshua. In fact, the above code example does exactly that. I use almost the same code for my archives, and use css to hide the linkless months. But you can style it any way you want, of course.

  61. 61 Jeff Adams June 5th 2008, 23:12

    I noticed that posts made today (as in the current day) don’t get counted. For example, if I have only one post in June and that post is today June 5 the month link for June doesn’t show up. However if I change the post date to June 4 it does show up. Is this by design or is it a bug?

  62. 62 Low June 9th 2008, 13:21

    Hi Jeff. It might be a bug, but I can’t say for sure, since I can’t duplicate it. Are you still having trouble with this?

  63. 63 matt June 27th 2008, 18:13

    thanks for this - works just as expected. amazing it’s not core to EE!

  64. 64 Timo July 27th 2008, 14:09

    I’m trying to use exp:weblog:entries under each month (a list generated with Yearly Archives) to show links links to each entry posted in that month.

  65. 65 Timo July 27th 2008, 14:15

    I’m trying to use exp:weblog:entries under each month (a list generated with Yearly Archives) to show links to each entry. I’m getting erros with the “month” and “year” parameters in exp:weblog:entries: “Warming: mktime() expects parameter 4 to be long, string given…”

    By manually typing in, for example, 2008 and 07 everything’s ok, but using tags generated by this plugin, {year} and {month_num}, I get that error.

    I’m able to get around this by embedding the exp:weblog:entries part of the code, but I would like to have this working right in the template where I’m using Yearly Archives.

  66. 66 Low July 29th 2008, 20:57

    Timo, I think you’re trying to use the plugin’s output to use as input for the exp:weblog:entries tag, right? But that probably doesn’t work because the latter is parsed before the former. Instead, why not keep the two separate and let EE’s dynamic URLs handle the input for the exp:weblog:entries tag?

  67. 67 Birdie September 30th 2008, 12:52

    THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU

    Sorry about that, but your plugin just saved me a massive headache!

  68. 68 Chuck October 14th 2008, 13:12

    Just a quick message to say many thanks for taking the time to create this plugin (which really should be part of EE’s core functions!). It has proved very useful for us and our clients, and i’m sure it will continue to do so. Keep up the good work :)

  69. 69 Mohammed Liyakhath November 6th 2008, 08:46

    Hi,

    This archive news is organized by the submitting date.

    How can i archived my news according to my customfiled (datedropdown in the cms).

    Thanks

  70. 70 Low November 6th 2008, 10:02

    How can i archived my news according to my customfiled (datedropdown in the cms).

    With this plugin, you can’t — it only uses the entry date. A custom date field is only useful for displaying a custom date. It’s not really possible to do anything else but sorting on that field. Not without a substantial amount of php, anyway.

  71. 71 Gabriel December 21st 2008, 21:45

    Hi Low. I’m running EE 1.6.6 build 20081114 and your sample code stop working. I get error:

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/hosts/system/core/core.functions.php(637) : eval()’d code on line 114

    The problem is in the {if num_entries > 0} {/if}
    When I remove this part of code, plugin start working.

  72. 72 Low December 22nd 2008, 09:30

    Hi Gabriel. I couldn’t reproduce with the latest build (20081212). Are you using php in your template?

  73. 73 Gabriel December 22nd 2008, 17:23

    Not, I’m not using php in the template. I will update the latest build 20081212 and I’ll see.

  74. 74 Gabriel January 15th 2009, 21:27

    Low, I tried the same code on other server and plugin working perfect. So the problem is on the server side on my webhosting. PHP on webhosting says “PHP Version 5.2.0-8+etch13″. Is there any special requirements to get start plugin working? The error line in core.functions.php contains code:

    return eval('?>'.$str.'<?php ');

    Coul you help me resolve problem?

  75. 75 Gabriel January 15th 2009, 22:18

    In addition script start working only if I remove all {if} comparations between {exp:yearly_archives} {/exp:yearly_archives}.

  76. 76 Gabriel January 15th 2009, 23:08

    These comparations produce error
    {if entries_in_year > 0} {/if}
    {if num_entries > 0} {/if}

    but this one works well

    {if leap_year == 1} {/if}

  77. 77 Low January 22nd 2009, 17:44

    Hi Gabriel. I still cannot reproduce your issue. Have you perhaps tried code like {if num_entries != 0} ... {/if}?

  78. 78 Eben January 22nd 2009, 23:56

    Hello,

    I’m new to EE, and I’m attempting to make an archive template that shows all the entries for a given year, such that a url like:

    domain.com/group/archive/2008

    …will show all entries from that year. I don’t understand why EE will only parse the URL dynamically when a month is also appended, or how I could override this after turning dynamic off. Can your plugin assist with this?

    Thanks!

  79. 79 Emily Lewis February 11th 2009, 21:52

    Is there a way to assign a limit? For example, I only want to list the 6 most recent months.

  80. 80 Low February 17th 2009, 10:33

    @Emily Lewis: I’m afraid not. But you could do something with the start_month parameter and php on input, I reckon.

  81. 81 Bo-oz February 18th 2009, 10:31

    Hi Low,

    Is there any restriction on the ’start-year’. I’m currently managing a site that uses your plugin, but it does not show items from 1965. (Sounds strange, but it has it’s uses). Is it maybe because you are using UNIX time internally? Easy fix?

    thx

  82. 82 Bo-oz February 18th 2009, 10:47

    Ik heb zelf al ontdekt dat je gebruik maakt van FROM_UNIXTIME om de entry dates op te halen (helemaal prima!). Helaas ondersteunt deze geen negatieve UNIX Timestamps. Ik denk dat ik dit uitzonderlijke geval maar ga ‘hard-coden’ in mn template. Ik zie geen oplossing die meer voor de hand ligt.

  83. 83 Bo-oz February 18th 2009, 10:50

    For your English readers ;) :

    This plugin uses FROM_UNIXTIME in the query, which does not support negative UNIX timestamps. Therefore any entry from before 1970 (which could happen when you use some exotic ways of organising things) will not be shown. So far, I cannot see any solution to this ‘problem’ which is only caused by the limitations of MySQL.

  84. 84 wbj May 24th 2009, 16:51

    Hi and thanks, this is very helpful. Like eben I am also wondering how to display entries by year only?

  85. 85 Low May 25th 2009, 14:10

    I don’t understand why EE will only parse the URL dynamically when a month is also appended, or how I could override this after turning dynamic off.

    Given a url like domain.com/group/archive/2008, EE will think that ‘2008′ actually is an entry_id, not a year. That’s why you can’t use the regular weblog:entries tag with dynamic=”on” to display entries by year. Instead you should use something like this: {exp:weblog:entries year="{segment_3}" dynamic="off"}

  86. 86 wbj May 25th 2009, 18:17

    Got it, thanks so much!

  87. 87 D. Shun-Luoi Fong May 25th 2009, 23:45

    I have a single entry (which is a pdf) per month, per year. I would like to list each month, grouped under each year as a heading. Each month is the url to the pdf itself. I was using the following code:

    <ul>
    {exp:yearly_archives weblog="{my_weblog}" start_year="1997" start_month="1" status="not closed"
    sort="desc"}
    <li>
    <h5>{year}</h5>
    <ul>
    {months}
    {exp:weblog:entries weblog="{my_weblog}" year="{year}" month="{month_num}" disable="pagination|categories|member_data|trackbacks" dynamic="off"}
    <li><a href="/media/pdf/resources/the-journal/{cf_tj_pdf}" title="">{entry_date format="%F %Y"}</a></li>
    {/exp:weblog:entries}
    {/months}
    </ul>
    </li>
    {/exp:yearly_archives}
    </ul>

    but it just gives me a blank page. If I understand an earlier comment you made, it is b/c the exp:weblog:entries tag is parsed first, so it doesn’t even know what {year} and {month_num} are.

    Is there a way to go about this with this plugin to accomplish what I am trying to do?

  88. 88 Low May 26th 2009, 10:44

    @D. Shun-Luoi Fong: nesting tags like that is generally a bad idea. You’ll end up with lots and lots of queries because you’re looping a weblog:entries tag. Performance-wise, that’s a big no-no.

    I’d recommend not to use this plugin to display actual entries. Instead, I think you’d be better off using just one weblog:entries tag, along with {date_heading display="yearly"} (see the docs).

  89. 89 wrb May 26th 2009, 17:25

    How would I your plugin to build a list of years without months?

  90. 90 Low May 26th 2009, 17:31

    @wrb: that’s easy, just don’t add the {months}{/months} variable pair.

  91. 91 wrb May 26th 2009, 18:39

    Like this?

    {exp:yearly_archives weblog="{my_weblog}" start_month="1" status="not closed" sort="desc"}
    {if year_count == 1}<ul>{/if}
    <li>
    {if num_entries != 0}
    <a href="{path={my_template_group}/{my_template}}{year}/" title="{num_entries} entries in {year}">{year}</a>
    {if:else}
    {month_short}
    {/if}
    </li>
    {if year_count == total_years}</ul>{/if}
    {/exp:yearly_archives}

  92. 92 Low May 26th 2009, 20:27

    Why not try and find out? :)

  93. 93 wrb May 27th 2009, 05:03

    I tried and got it to work, thanks! ;)

  94. 94 Emily H May 29th 2009, 19:49

    I just wanted to share a variation on the usage of this excellent plugin. I am using it to show a list of months, but without displaying the year. The reason for this is explained more in my comment on another of Low’s posts, about how to get all entries from a given month, regardless of the year.

    Basically it is a blog about seasonal/month specific topics which you might want to browse by month, but wouldn’t need to browse by year.

    Essentially I just stripped out any references to the year. I also have a non-linked month item set to be displayed if there are no entries, but this isn’t set to show up until that month of the year has passed.

    <h2 id="archives_month">Archives by month</h2>
    {exp:yearly_archives weblog="woods_pages" status="Published" sort="desc"}
    <ul class="yearly_archives">
    {months}
    {if num_entries > 0}
    <li>
    <a href="/{segment_1}/month/{month_num}/" title="{num_entries} entries for {month}">{month}</a>
    </li>
    {if:else}
    <li>
    {month}
    </li>
    {/if}
    {/months}
    </ul>
    {/exp:yearly_archives}

  95. 95 aliotsy July 24th 2009, 20:03

    Hi Low,

    Is there any way to use this plugin with a custom date field?

    Not sure if it matters, but I’m listing entries using Solspace’s Date Field Filter plugin.

    Thanks!

    Aliotsy

  96. 96 Low July 27th 2009, 15:12

    Hey aliotsy, I’m afraid not. The plugin uses the entry dates to generate the output.

  97. 97 Hambo October 1st 2009, 06:38

    Hi there,

    I just want to have two years displaying in two columns. Is there a way to dynamically assign last years year to the start_year parameter instead of hard coding it?

    A display_years parameter would be welcome so I can display for example if I added display_years=”3″ then I would get -

    2009
    2008
    2007

    PS. You’re website still says you are 31 ;)

  98. 98 Low October 5th 2009, 12:03

    Hey Hambo, if I understand correctly, what you’re really after is something like an ‘offset’ and ‘limit’ parameter for the years to display, right? Guess you could use PHP on output for now. I’ll see if I can add those to the plugin for the 2.0 release. :)

  99. 99 bigDog October 21st 2009, 20:54

    I am trying to figure out how to not show items that are empty. Some of the months in my output have no entries bit the month is still out put. Is there a fix for that? Thanks.

  100. 100 bigDog October 21st 2009, 21:52

    Do not worry I found the line to remove. Thanks.

  101. 101 Lyubov Berezina November 6th 2009, 12:58

    Hello!
    Thank you for your wonderful plugin! However when I’m trying to use it I receive the following error:
    Deprecated: Function ereg() is deprecated in C:\xampp\htdocs\vulichenko\system\plugins\pi.yearly_archives.php on line 230
    The years list is populated though, but this error does bother me. Could you please comment on this?
    Thanks a lot!

  102. 102 Lyubov Berezina November 6th 2009, 13:29

    I’m using EE 1.6.8, Apache/2.2.12, PHP Version 5.3.0
    Hope this info is of any use regarding my problem :)

  103. 103 Low November 6th 2009, 13:33

    Hey Lyubov, yeah I figured you were using php 5.3. I’ve replaced the said function, so the error should be history. I’ll upload the new version shortly, but in the mean time, you can grab your copy from GitHub, if you want.

  104. 104 Lyubov Berezina November 6th 2009, 14:50

    Low, thanks a lot! That was super fast :)
    It now works like charm.
    Thanks again for your great job.

  105. 105 Sean December 2nd 2009, 11:25

    Low,

    I just updated to the latest version of EE 1.6.8 build 20091201 and am now getting an error with this plugin.

    When not logged in, it only links to the latest month, but when I am logged in (as superadmin) it displays the following error - between the year and the month)

    Notice: Use of undefined constant dFXcfcd2FALSE8495d565ef66e7dff9f98764da - assumed ‘dFXcfcd2FALSE8495d565ef66e7dff9f98764da’ in /path/to/system/core/core.functions.php(634) : eval()’d code on line 11

    my template code looks like this and was working prior to updating to build 20091201:


    <ul class=“yearly_archives”>
                    
    {exp:yearly_archives weblog=“blog” start_month=“1″ status=“not closed”
                    
    sort=“desc”}
                      
    <li class=“months”>
                        
    {if leap_year == 1}<em>{year}</em>{if:else}{year}{/if}
                        
    <ul>{months}
                          {if num_entries 
    0}
                          
    <li>
                              <
    a href=“{path=blog/archive}{year}/{month_num}/”
                    
    title=“{num_entries} entries in {month} {year}”>{month}</a>
                            </
    li>        
                            
    {if:else}
                            
    <li class=“emptymonth”>{month}</li>
                            
    {/if}
                          {
    /months}
                        
    </ul>
                      </
    li>
                    
    {/exp:yearly_archives}
                    
    </ul

    Hope you can help me out here.

    Thank you

    Sean

  106. 106 Sean December 2nd 2009, 11:27

    re: above comment - if I remove the archives there is no error on the page at all.

    There should be archives back to September but when not logged in it only shows November now - you can view the page at http://repatriate.me

    Thank you

  107. 107 Low December 2nd 2009, 11:29

    Sean, looks like the newest build made some changes to how it handles {if…} statements. I’ll take a closer look as soon as I can.

  108. 108 Low December 6th 2009, 17:14

    My hunch was right. I’ll investigate some more, but for now, you can fix errors by changing the if-statements slightly. Instead of {if num_entries > 0}, use {if "{num_entries}" > "0"}. (and fix the leap year conditional in the same way)

  109. 109 Sean January 17th 2010, 04:30

    Low,

    yeah that fixed it. Sorry for taking so long to get back to you on that.

  110. 110 vlado varbanov March 2nd 2010, 18:38

    hello I’m using this plugin as well and I found that it doesnt display entries from this (2010) year. It does display however entries from 2008 and 2009. In 2010 I have future and past entries which are missing as I said in the results. I’m using

    {exp:yearly_archives weblog="{wb}" sort="asc" show_expired="yes" show_future_entries="yes"}
    <li> <a href="{path='{tg}/view'}">{year}</a></li>
    {/exp:yearly_archives}

  111. 111 Michael Rubens March 7th 2010, 18:21

    When using the {months}{/months} tags pair, is there any way to ONLY display those months where entries exist?

  112. 112 Michael Rubens March 7th 2010, 18:31

    Looks like I answered my own question:


    //
    //Display only months where entries exist
    //
    {exp:yearly_archives weblog=“gallery” start_month=“1″ status=“not closed” sort=“desc”}
    {if 
    “{year_count}” == “1″}<ul>{/if}
    <li>
    {year}
    <ul>
    {months}
    {if 
    “{num_entries}” != “0″}<li>
    <
    a href=“{path=blog/archive}{year}/{month_num}/” title=“{num_entries} entries in {month} {year}”>{month_short}</a>
    </
    li>
    {/if}
    {
    /months}
    </ul>
    </
    li>
    {if “{year_count}” == “{total_years}”}</ul>{/if}
    {
    /exp:yearly_archives} 

  113. 113 Andrew Rodgers April 12th 2010, 20:39

    Great plugin! Any way to have the archives loop paginate?

  114. 114 Low April 13th 2010, 09:23

    Andrew, there is no pagination natively. The only way I can think of, is by setting the start_year and end_year parameters manually.

  115. 115 Andrew Rodgers April 13th 2010, 18:10

    Thanks for the quick response,
    I’ll let you know if we come up with a good solution to this. Thanks again and keep up the great work!

  116. 116 Steven Hambleton April 14th 2010, 16:59

    Hi Low,

    I’m getting really odd behaviour on an MSM site. I only have 1 entry in the news channel but the yearly pluging is reporting -

    Apr - 9 articles
    Mar - 25 articles
    Feb - 26 articles
    Jan - 26 articles

    I have no idea where it’s counting these article!

    My code is -


    {exp:yearly_archives weblog=“news” start_month=“1″ end_month=“12″ start_year=“{current_time format=”%Y“}” monthsort=“desc”}
    <li>
        
    {year} {entries_in_year}
        
    <ul>
            
    {months}
            {if num_entries 
    != 0}
            
    <li><a href=“{path=news/archive}{year}/{month_num}”>{month_short} (“{num_entries}” article{if num_entries != 1}s{/if})</a></li>
            
    {/if}
            {
    /months}
        
    </ul>
    </
    li>
    {/exp:yearly_archives} 

  117. 117 Steven Hambleton April 14th 2010, 18:12

    It seems to be picking up news weblogs across all sites.

    SELECT FROM_UNIXTIME( entry_date, ‘%Y%m’ ) AS ym, COUNT(*) AS num_entries FROM exp_weblog_titles t INNER JOIN exp_weblogs w ON t.weblog_id = w.weblog_id WHERE 1 AND ( expiration_date = 0 OR expiration_date > UNIX_TIMESTAMP() ) AND entry_date < UNIX_TIMESTAMP() AND status = ‘open’ AND blog_name = ‘news’ GROUP BY ym ORDER BY ym ASC

  118. 118 Steven Hambleton April 15th 2010, 02:19

    Perhaps a site parameter is in order?


    SELECT FROM_UNIXTIMEentry_date‘%Y%m’ ) AS ymCOUNT(*) AS num_entries FROM exp_weblog_titles t INNER JOIN exp_weblogs w ON t.weblog_id w.weblog_id WHERE 1 AND ( expiration_date OR expiration_date UNIX_TIMESTAMP() ) AND entry_date UNIX_TIMESTAMP() AND status ‘open’ AND blog_name ‘news’ AND t.site_id ‘32′ GROUP BY ym ORDER BY ym ASC 

  119. 119 Low April 15th 2010, 10:34

    Steven, I’ve updated the plugin so it now supports a site_id parameter. Does that help?

  120. 120 Steven Hambleton April 15th 2010, 11:11

    Awesome thanks Low! I’ll test this later.

    PS. Thanks for the name edit ;)

  121. 121 Dan Diemer May 16th 2010, 11:36

    Valdo is correct. This doesn’t seem to work with the year 2010 for some reason.

  122. 122 Steven Hambleton June 23rd 2010, 11:44

    Is there a problem with 1.6.9? I just get -


    {YEAR_SHORT}
    {
    /year} {year} 

  123. 123 Steven Hambleton June 23rd 2010, 11:54

    Disregard my last post. Work fine :)

  124. 124 Marcus Neto June 30th 2010, 18:40

    Low, I inherited a site that uses this plugin. I am trying to get it to limit the years to 2010-2008. The site is EE 1.6.8 but your plugin is the latest (1.6). The code I have is:

    {exp:yearly_archives weblog=”news” start_year=”2010″ status=”not closed” end_year=”2008″ sort=”desc” show_expired=”yes”}
    {if entries_in_year > 0}
    <h3>{year}</h3>
    <ul class=”archivelist”>{months}
    <li>
    {if num_entries > 0}
    {month}
    {if:else}
    {month}
    {/if}
    </li>{/months}
    </ul>
    {/if}
    {/exp:yearly_archives}

    But it is still outputting the 2006-2007 years as well. What am I missing?

  125. 125 Low June 30th 2010, 20:01

    Hey Marcus,

    Can you try reversing start_year and end_year? So: start_year="2008" end_year="2010"

  126. 126 Marcus Neto June 30th 2010, 22:22

    Low, sorry bout that. I must have been editing the wrong file on the server. Scratch one up to a lack of coffee this morning. It works as you designed. Thanks for the help!

  127. 127 Gildebrando Hollon Jr. July 26th 2010, 03:47

    Low, i have query at my database of MSSql 2000 server using PHP 5+ and Apache 2 Server

    the example value is “Jul 3 2010 12:00:00:000AM”;

    <?php

    $DOCDATE = “Jul 3 2010 12:00:00:000AM”;

    $result = strftime(”%m/%d/%Y”, strtotime($DOCDATE));

    echo $result;

    //the result is 01/01/1970

    //i want a result of 07/03/2010
    ?>

    before, i use an old version of PHP and FreeTDS it works fine! now i don’t know what is

    hope u help me!

  128. 128 Low July 26th 2010, 08:27

    Gildebrando, your question has nothing to do with ExpressionEngine, so I suggest you look for help at more appropriate channels.

Leave a comment



Some html (a, em, strong, etc) allowed.
Email won’t be displayed and takes care of your Gravatar.