WordPress Plugin: Collapsible Archive Widget

Update: 20 January 2010: This plugin has not been tested with WordPress 2.9 and may break because 2.9 has internal changes. I am still trying to find time. Sorry for the Inconvenience.

I have written another simple WordPress plugin that simply display a collapsible archive in the sidebar. You can see it in action in the rightmost sidebar of the main page.

When the sidebar loads, it is in collapsed state and can be expanded by clicking the years. It utilizes simple JavaScript that shows and hides a div containing the monthly links. The purpose of this plugin is to save space on the sidebar especially if you have been blogging for a while. It is an alternative to the combo box (select) provided by the default archive widget.

My request for the plugin to be listed in the WordPress Plugin Directory has been pending for a while so for now it can be downloaded here.

The plugin can now be downloaded here.

Configuration:

  • Widget Title: the title of the widget
  • Show post counts for year: Whether or not to show the post number for each year
  • Show post counts for month: Whether or not to show the post number for each month
  • Abbreviate month names: Check this box to show abbreviation of month names
  • Hide year from month names: Do not print year after month names
  • Use script.aculo.us effects: Whether or not to show effects
  • Expand effect: Effect to use when expanding the list
  • Collapse effect: Effect to use when collapsing the list
  • Expand the list by default: Check this box to have the list expanded when loaded
  • Expand current year by default: Check this box to have the current year expanded when loaded
  • Expand current month by default: Check this box to have the current month expanded when loaded
  • Show individual posts: Show posts in the list. This should be used in extra caution; if you have a lot of posts consider disabling it as this will take time to load
  • Use HTML arrows instead of images (► ▼)
  • Show current month in bold: show current month in bold
  • Show a link to plugin page. Thank you for your support! : Display a link to plugin page (this page) as a support method

Current Version: 2.3.1

Installation

Copy the file to the wp-content/plugins/widgets directory and activate it in the Plugins page. Then drag and configure it in the Sidebar Widgets page.

Warning: Will only work on widgets enabled blogs.

TODO (these are being considered but there is no guarantee when they are going to be included)

  • Add ability for multiple instances
  • Add ability to work as non-widget
  • Add ability to include / exclude categories
  • Expand previous month rather the current
  • Research the practicality to use CSS / allow CSS options
  • List posts without year and month headers (for blogs with few posts)
  • Do not list the posts that are listed on the main page

Change Log

  • 03-Aug-2007: Initial version
  • 04-Sep-2007: Added ability to select whether to use abbreviations for the month names, and script.aculo.us effects!
  • 27-Sep-2007: Fixed javascript include – effects.js added and scriptaculous.js removed (For some reason it worked in 2.2)
  • 10-Nov-2007: Added ability to display posts (with caution), to expand by default, and also added plus and minus signs as expand/collapse buttons
  • 24-Aug-2008: Multiple updates:
    • Enqueue javascripts using WordPress API wp_enqueue_script
    • Validation as XHTML 1.0 Transitional
    • Add option to expand current year and/or month by default
    • REMOVED list type option
    • Added ability to upload own plus and minus images
    • Added ability to display plugin link. If you’d like to support this plugin, having the “powered by” on your blog is the best way; it’s our only promotion or advertising.
  • 25-Aug-2008: Bugfix to not load javascripts when effects is not used
  • 25-Aug-2008: Javascript code factoring and added ability to use HTML arrows
  • 16-Mar-2009: Separated year and month posts counts, added option to hide year after month names, ability to show current month in bold, enabled localized title
  • 17-Mar-2009: Fixed valid XHTML, and highlight (bold) bugfix


BIG FAT WARNING

The ability to display posts is provided after receiving so many requests for it. This feature is not practical for those with many posts in a month. Enabling it means that there is a lot more data that needs to be received by the browser, not to mention the load on the database. It is, however works very nice for blogs with low post count. Please use at your own risk and remember to test it.

Notes:

11-Nov-2007: I’d like to thank Meitar Moscovitz who tried his best to provide a patch to display posts in the list. I rewritten some of the code for version 2.1 based on his logic. Thank you!
25-Aug-2008: Thanks to Berny for his idea of re factoring the javascript code and also for providing HTML arrows option.

If you find this plugin useful, feel free to


0 Shares

132 thoughts on “WordPress Plugin: Collapsible Archive Widget”

  1. Hey that is actually a cool suggestion. I’ll try to see whether I can utilize the scriptaculous js files already distributed with WordPress 😀

  2. This is great, but is there any way to change the format so it displays the full month (eg. August 2007 rather than Aug 2007)?

    (Apologies if this is a really stupid question as my tech knowledge is next to non-existent)

  3. Andy, no that is a very good and valid question. Currently that is not possible because of the way I code it. However I will add it soon to the next version as a setting option. That’s actually very easy to implement. I’ll let you know when the new version is ready.

  4. Any chance in an upgrade to also show individual post titles under the months in collapsible style as well.

    Ie:
    2007
    -August
    –This is one post
    –This is another post
    -September
    –This is one post
    –This is another post

    Thanks for the fantastic plugin!

  5. Mycal: That is very possible however don’t you think it’ll be too much for the sidebar? Anyway I think that is not for me to decide, it’s for the users. I’ll add that capability to the next version ASAP.

  6. hello
    you’re pluggin widget is just wonderful !! It rocks!
    however, i’d like to use it for “categories”. I tried hard but I just don’t manage to change the code so that it works for ‘categories’.
    Would you help me? Thank you !

  7. Kalilive:

    This plugin does not handle categories, and might probably be broken now with WordPress 2.3. Isn’t there any existing plugins that handle categories in the same way? If not I can consider writing one.

    Anyway, I am analyzing compatibility with WordPress 2.3 now. I’ll let you know.

  8. Since this plugin does not use the database extensively, it was not effected by WordPress 2.3 database change. But a minor fix for scriptaculous includes has been made to version 2.0.1

  9. I agree, this is a lovely widget, but I’d also like to see functionality that allows for the individual posts themselves to appear in the list of archives. Also, it seems to make more sense from a usability standpoint to automatically expand the current month’s list of posts to give the reader some orientation. (Blogger’s hierarchical archives widget is a good example of exactly this sort of thing.)

    In fact, I have a project on which this functionality would be welcomed very soon. If I get around to it, would you mind accepting a patch for this feature, Ady?

    Thanks again for a lovely head start and a great widget.

  10. Thanks all for your kind words and suggestions. I shall try to find time to fork this project into categories (in a separate plugin).

    Meitar: sure if you don’t mind me changing it later as I am very particular about code readability and cleanliness 🙂

  11. I’d love to use this plugin, but want to show uniformity with my category list. So, I’ll cross my fingers and hope that this gets forked over into that. I was using WP-dTree, but that ceased to function with the taxonomy of WP 2.3. Also, that plugin hasn’t been developed in over a year with no way to contact the author. So, I’m hoping ady can come up with something.

  12. All

    I have updated the plugin to version 2.1 with these new features:

    1. Ability to display posts (please see warning above)
    2. Ability to have the list expanded by default
    3. Plus and minus signs for collapse/expand

    I had some help from Meitar for the posts. Thank you.

    For the categories, I am thinking of a separate plugin. Can you give suggestions on how it should work? Categories expand to posts as a tree?

    Cat1
    – post1
    – post2
    Cat2
    – post3
    – post4

    Like that?

  13. Thanks alot Ady!

    This plugin is everything I want now (since I don’t use categories). It was well worth the wait for the post names. Again, thanks a lot and absolutely love the plugin. Keep up the fantastic work!

  14. Mycal: Glad you liked it.

    Daniel: Yes, I’ll try to find time to update.

    Michael: Most probably your WordPress does not come with scriptaculous. An old version? Let me know what version of WordPress you are currently using.

Comments are closed.