
NOTE Concerning WordPress 2.2:
I have not upgraded my blog to 2.2 yet, and cannot speak to the compatibility of this plugin with WP2.2.? If you’ve tried it, please share with me your results!
NOTE: My apologies to everyone who’s had a problem with the stupid “Line 67″ error message on this plugin! I’ve finally fixed it, and the plugin should work fine, now. additionally, I’ve dropped support for the RAR version of this file. Only the ZIP file is downloadable now because keeping up with four separate files (2.0.zip, 2.0.rar, 2.1.zip, 2.1.rar) wasn’t making support any easier on me!
Note: This plugin has become popular enough to warrant it’s own separate page, so the original post page is no longer being used.
Note: I have forked the development of this plugin out of necessity. WordPress 2.1 changes the way Categories and Links are ordered in the database, therefore a small change needed to be made to the plugin that does not make sense for 2.0.* users. Additionally, the ‘get_settings’ keyword has been deprecated in the current version of WP, so this has been changed in the 2.1-compatible version, but not the 2.0-compatible. Please make sure you download the proper version of the plugin for your version of WordPress.
This Widget uses WordPress Categories which have Parent to Child relationships to create a collapsible list of Categories for your weblog. Let me stress: you must have Categories that have child Categories for this to work, as the child Categories will be the ones that get rolled up in the collapsed list. If you are unfamiliar with what this means or why you would want to use it, see this page of the WordPress documentation for a bit of guidance.
In the time since I published my last Widget, the Folding Categories Widget, I’ve been surprised that no one has seemed to have developed an animated version using JavaScript. Now that I’ve done it, I’m less surprised: it was a big pain in the butt.
What you see below is the culmination of my first completely-original Widget, the new JavaScript Animated Collapsing Categories Widget. I opted to come up with a slightly different, longer and more descriptive name for the new Widget since the original is based on code from WebSpaceWorks.com, whereas this is entirely of my own creation. I’ve added a few features that people have asked for, along with some that I thought might also be a nice touch, and I can now use a legitimate version number that reflects the changes to the widget.
Features:
- The ability to display a compact list of top-level Categories and allow users to expand the list if they so desire.
- NO NEED FOR PAGE RELOAD! The major improvement over the previous version is that, because this version uses JavaScript, you do not need to reload the page every time someone expands the list. This avoids the confusion that the original Widget caused.
- Two separate sorting options for the Top-Level and Child Categories, along with the option to sort in Ascending or Descending order. All child Categories below the first child (second, third generation) will be bound to the first child’s setting.
- For the sake of keeping your site’s look and feel, I’ve provided an option which will allow you to set the CSS class name of both the Top-Level and Child Categories.
- You also have the option of setting the displayed name of the Categories as either the Category Name or as the Description, if you’re used to that option in WP.
- The same options are available for setting the link’s TITLE attribute.
- The option to show the post count in each Category is also available.
- Support for an unlimited hierarchical depth. If you’ve got great-great-great-grandchildren, this Widget will handle them. Whether your sidebar will have room is another story. . .
For WordPress 2.0.*:
Version History
- v1.0 ~ Initial Release
- v1.1 ~ Minor changes to documentation
- v1.2 ~ makeLink function added to remove category base bug
- v1.3 ~ col_cats_init (renamed from inexplicably named Scriptaculous_init) now calls variables for plus and minus signs so the plugin isn’t calling *my* website for these files (whoops!!).
Manifest
- Collapsing_Categories.zip
. . . . . – README.txt
. . . . . – collapsing_categories.php
. . . . . . . . . . | col_cats
. . . . . . . . . . – col_cats.js
. . . . . . . . . . – minus.gif
. . . . . . . . . . – plus.gif
. . . . . . . . . . – blank.gif
Installation Steps:
- Download the file found here as a ZIP file.
- Unpack the contents. You will find a collapsing_categories.php file and a folder (see manifest above).
- Upload the items to your wp-content/plugins folder on your webserver. Both the file and the folder should appear in the root of the /plugins folder.
- Activate the Widget in the “Plugins” page of your WordPress Administration Panel.
- Go to your “Presentation” page and click on “Sidebar Widgets,” place and configure your Collapsing Categories Widget.
For WordPress 2.1.*:
Version History
- v1.0 ~ Original rerelease of the Widget for WP2.1 compatibility. Removes Link Categories from listed Categories
- v1.1 ~ Modified to remove references to deprecated “get_settings” function cite: http://markjaquith.wordpress.com/2006/08/30/get_settings-is-deprecated/
- v1.2 ~ makeLink function added to remove category base bug
- v1.3 ~ col_cats_init (renamed from inexplicably named Scriptaculous_init) now calls variables for plus and minus signs so the plugin isn’t calling *my* website for these files. (whoops!!)
- v1.4 ~ “get_options” mistakenly used instead of “get_option.” This has been corrected.
- v1.5 ~ Upgrade users of WP2.1 do not get “blogroll” Category created, so the condition testing whether or not a Category is a Link Category had to be adjusted
Manifest
- Collapsing_Categories_wp21.zip
. . . . . – README.txt
. . . . . – collapsing_categories_wp21.php
. . . . . . . . . . | col_cats
. . . . . . . . . . – col_cats.js
. . . . . . . . . . – minus.gif
. . . . . . . . . . – plus.gif
. . . . . . . . . . – blank.gif
Installation Steps:
- Download the file found here as a ZIP file.
- Unpack the contents. You will find a collapsing_categories_wp21.php file and a folder (see manifest below).
- Upload the items to your wp-content/plugins folder on your webserver. Both the file and the folder should appear in the root of the /plugins folder.
- Activate the Widget in the “Plugins” page of your WordPress Administration Panel.
- Go to your “Presentation” page and click on “Sidebar Widgets,” place and configure your Collapsing Categories Widget.
That’s it!
You should now see your Categories arranged in the way you wanted and expanding and contracting to your heart’s content.
Some additional notes for customization:
- The plus sign, minus sign and blank square GIF images used for this Widget’s navigation are contained in the /col_cats directory included with this Widget. Should you wish to use different icons, just replace the ones I’ve given you with your own images of the same name. Note that the current files are 10x10pixel images, but you can use whatever size you want.
- Its probably advisable to set whatever CSS Classes you are using for the Widget with, at minimum, the attribute “list-style-type: none;” if you do not already have that option inherited in your Template. Otherwise, you get a bullet in front of each Category, which will look messy with the navigation buttons.
- If your styling is not working, remember that you are likely inheriting other style attributes from lists in your sidebar. You may need to spell out exactly where in that inheritance scheme your Widget lies in order for it to work correctly, like so: “#leftsidebar ul ul ul.col_cat_child li { border-style: none; }“






