JavaScript Animated Collapsing Categories
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 10×10pixel 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; }“

Loading ...
Posted by Thomas Belknap on February 20th 2007. This post has not been tagged.
[...] JavaScript Animated Collapsing Categories uses WordPress Categories which have Parent to Child relationships to create a collapsible list of Categories for your weblog. (No Ratings Yet) Loading … [...]
[...] Alt kategorileriniz için, aç?l?r menu yapmak için, buradaki eklentiyi kurman?z yeterli. Kurulum için yapman?z gereken, plugins klasörününe upload etmeniz ve onu aktif etmeniz. Sidebar widget den, istedi?iniz bölüme atman?z gerekiyor. ?u an benim için “not found” hatas? verdi. Siz çal??t?rd?ysan?z, ayarlar?n?z? söyleyin [...]
[...] My recent JavaScript Animated Collapsing Categories list is probably going to need to be retooled to not include link categories, but until I know exactly how those two are going to combine, I won’t know for certain how. I trust all will be explained in time. [...]
For those of us not as familiar with Java and CSS as we might be (and bearing in mind that you don’t have complete access to my CSS files, if the style-sheet for my theme has this in the “sidebar” section of style.css:
#sidebar ul{
list-style:none;
}
and then slightly lower:
#sidebar .sideitem ul{margin-left:-4px;
}
then why won’t this work:
#sidebar ul ul ul.col_cat_parent li {list-style-type: none;
}
#sidebar ul ul ul.col_cat_child li {
list-style-type: none;
}
I’ve also tried reducing the “ul level” by one in case that worked, but to no avail. As you say in the ReadMe.txt, it’s a bit messy with the inclusion of bullets. Not horrible, just not elegant.
OK, I’ve taken the liberty of looking at your HTML to see what the inheritance scheme might be. Note: you do not have an opening BODY tag, but you do have a closing one, so your web page will not validate, at minimum. This may also be having unforseen consequences in terms of your CSS, so use caution and maybe double-check your validation. Here is a starting point, direct from the W3C.
In any event, based on what I’ve seen, you might have to do something along the lines of:
#sidebar ul ul li.sideitem ul.col_cat_parent {
list-style-type: none;
}
#sidebar ul ul li.sideitem ul.col_cat_child {
list-style-type: none;
}
Try that and see if it works for ya!
Thanks for using the Widget!
Aha! Due to over-enthusiastic cutting and pasting I pulled the body tag that started that in the latter portion of the Header file (and why the body starts in the header is beyond me, but… whatever…) So that’s all good now.
And, after using your suggestion about the style.css editing, I’m finding the same results. The list is defined as follows:
So… should I be chucking that “top_level” bit in there somewhere? I’m happy to tinker if I know what direction to head in…
Well, the body should not be in the header, that’s not going to work, either.
But, you could try just styling #top_level and see if that works as well. I didn’t see any other nesting weirdness going on with your template, but it’s definitely a bit wonky. Perhaps you should look around for a more rational template?
I should be more specific - it’s in the header.php file, and the original design actually has it there. Odd.
The footer.php file has the end of the body tag as well.
Sidebar.php has about 87 inner-stacked levels of “ul” as well as the calls for the widget functions.
And, possibly, after WordPress 2.1 ships it’ll all be an even larger mess.
{heavy sigh}
Why did I start this whole blogging thing again? Oh right: “fun”…
Well, WP2.1 isn’t going to make too much of a difference to the layout of your Templates. In fact, any template I’ve tried with 2.1 has worked fine. The biggest difference will be that Links are now held in Categories, so I’m currently trying to set aside time to retool this Widget to accomodate the changes. Hopefully tomorrow.
What you might want to do is study your CSS and see how it’s using inheritance. If it’s just calling out ULs of the same depth by themselves, or if it’s calling them by “ul ul ul ul.something.” That will tell you a lot about how it expects you to style things.
What is the tempate, by the way?
Oh, yeah. Something rather obvious just dawned upon me: have you tried going into the options for the Widget and changing the Class name to “sideitem,”? That might move us beyond the whole problem. . . . . .
Nope. For a moment I had a feeling of hope! “Brilliant! Why didn’t I try adjusting the widget to comply to the CSS… oh… because it doesn’t work. Damn.”
I even tried returning the child to the previous setting in case I could see a difference that might lead to a solution… and no.
Intense 1.0 by Sadish Bala
WP Theme Intense by Sadish Bala, based on this design by sofaspud
That’s the naughty naughty theme.
Hi,
I’m sorry but not a genius in PHP and HTML. What am I supposed to do when you say: “place and configure your Collapsing Categories Widget”
Thanks
hi, this is a great plugin!
but I’d like to use it for the pages list too (not only for categories). How can I do? Does another plugins exist ?
Thanks!
@Vincen: You need to drag and drop the Widget where you’d like it to be, just like any other Widget.
@Stevetk: At present, I do not have any such plugin for pages. In truth, I guess I never thought anyone would be using so many pages. . .
@I.A.M: OK, let me look at that one and get back to you shortly. . . .
I see in the .js code that the default display is supposed to be collapsed. The opposite is actually occurring at my site. Any ideas?
Scratch that… seems to be working now. ??
Thomas;
My site is now using the usual category display, and people are finding it loads slower than they would like, and I’ve stripped it of a few other things as well, so I suspect the theme is causing more than a few problems than simply this plug-in not being happy.
End result: I’m hunting for a new theme now, so sit back and wait for me to do change that, then I’ll implement the plug-in and we’ll see what happens then.
All personnel, stand down.
Aye, aye, Cap’n. I’ll await your next transmission.
[tap tap]
Attention! Attention! All systems are now operational! I repeat, all systems are operational, and bullets continue to occur with “Mandigo” found at that link there! Style sheet seems orderly, as do other files, but hierarchical stacking of bullet levels continue to confuse!
Thank you. That is all.
I can play / Faster and louderI can dance / Faster and louderI can live / Faster and louder…
So… again bowing to other people’s desires…
……
Ugh!
Try either:
ul li ul.col_cat_parent {
list-style-type: none;
}
or
ul.sidebar li.collapsing-categories ul.col_cat_parent {
list-style-type: none;
}
…and, sadly, it doesn’t seem to have helped. I tried both, including ensuring there were spaces where they we to supposed to be in case line breaks were not sufficient for the php to recognise the style specified, but it wasn’t sucessful.
I thank you very much for the large amount of your time willingly given for this, and place the solution’s elusiveness as being a result of conflicting code in either another plug-in I have or in the server-side php version, or something otherwise outside of your control.
The plug-in itself works a treat, I just can’t figure out how to make it appear seamlessly within my theme, and do not think less of either your work developing the plug-in or with me.
All the best, and keep doing what you’re doing both with development of plug-ins, and fighting the good fight with this political blog.
[holds clenched fist in air]
¡Viva la Revolution!
Any ideas how to edit this plug-in to collapse my blogroll?
Thanks!
I’ve been procrastinating in coming up with a new version (or really, a fork) that allows this plugin to work with the new WordPress. I mean, it works, but it should really provide what you ask: the ability to work with the new Link Categories.
I think perhaps I’ll get crackin’ on that today, since you’re the first to have asked!
hi there thomas..
my site has a bit of java that would normally move down when you hover on the top area.. please check my site but with your plugin activated it stops my java dropdown completely.. is there something i can resolve this? I am using the striped plus theme..
I have a small problem. The plugin loaded fine and it works as described except for something I did that now links the categories to, say, …/category/tropical-plants (which comes up in error) instead of to …/?cat=14 like the rest of the links on the site.
What did I do wrong and/or how can I get it to start working? I’m using it with wp2.1.
I apologize for asking such a dumb question but I don’t have a clue and I love and need what this plugin is supposed to do.
Nevermind. I figured it out.
This plugin works great. Thank you very much, you old wobbly, you.
hi there
@Freeeye.. actually i am new and wondering how did you get rid of that error.. i am getting this error i think similiar to what freeeye says
The requested URL /walkthemile/category/news-flash was not found on this server.
when i click on a category…
@Thomas or anyone else.. is there an option to have the list by default to show all expanded..
@kim: The problem is the link structure settings (”Options > Permalinks”). You need to make sure that, if you’ve changed this setting, you change it back because the permalinks held in the database will differ from what WordPress expects and thus WordPress won’t be able to find what you’re looking for.
No, there is no option to expand by default, but I’m working on a new version for WordPress 2.1, so I’ll keep this in mind as an option to add in!
@freeeye: Glad you found what you needed to fix! Sorry, I’ve been a bit busy and support for this Widget has been a bit lax. . .
thanks for your help Thomas.. But what should it be in the options permalinks.. i have it set as “default “which is ../walkthemile/?p=123
and the “optional , Category base” is:/category
is this what it should be set too?? or????
Well, OK. It would appear as though the way I wrote the code hard-codes it to the following format:
blogurl/category/category_nicename
In other words, no Category base at all. That would be a design flaw I’m going to need to adjust on a later release. For now, if you leave the Category base blank, it should work.
hey thomas..
i tried leaving it back to default and removing all from category base and i unfortunately still get the error.:
The requested URL /walkthemile/category/phone was not found on this server.
any other ideas i can do while the next release? or when might the next release be??
cheers.. thanks for you time thomas!
Kim, I had to set the permalinks to custom:
/%category%/%postname%/
There are many custom settings and you may need to find the one that applies to your situation. They are described somewhere in the wordpress labrynth. Good luck.
This also involved setting up an .htaccess file for for the site for the modification.
I don’t know much about doing this sort of stuff so this may not apply in your case. I kind of wing-it and stumble along. This worked perfectly in my case, tho.
I would love to use your widget - but when I activate the plug-in, I get the following error message that takes over my website (www.horatiostreetblog.com). I’m running the MistyLook theme on Wordpress 2.1. Any ideas? The plug-in is currently deactivated so my website can be seen.
Fatal error: Call to undefined function: get_options() in /home/horatios/public_html/wp-content/plugins/collapsing_categories_wp21/collapsing_categories_wp21.php on line 251
Dang!!! Sorry, Julie!
Big, stupid typo in my script, I don’t know how I missed it. Musta mixed up some files. Should be working now, though!
Thanks so much for creating this widget, Thomas! It was exactly what I was looking for
Is there a way to exclude/hide categories, though?
No, I’ve not developed any way to do that, just yet. Perhaps in the next release I will add that in. Thanks for the suggestion, it’s a great idea!
[...] JavaScript Animated Collapsing Categories [...]
I’ve had some issues trying to enable this plugin. I did eventually get it working, but I was wondering if the problem is a lack of understanding on my part (I’m just getting started on the Wordpress thing).
- I started with a vanilla download of Wordpress 2.1, then I added the K2 theme. I then pulled down the collapsing_categories_wp21.rar and extracted it into the plugins dir. But, when I try to activate the “Javascript Animated Collapsing Categories Widget for WP2.1.*” plugin, it borks Wordpress (i.e. blank pages for all links from there on). I have to delete the files from the plugins dir for Wordpress to come back.
- So I pulled down the collapsing_categories.rar file instead. It has two “collapsing_categories.php” files (both version 1.3), which results in Wordpress showing two plugins. The dir structure also appears to be wrong.
- I did a diff and found that the only difference is in the content of the makeLink() function. So I deleted the one that seemed older, shuffled the dir structure to what I thought it should be, moved it over the plugins dir, and success!
Whew! So, although I got it working eventually, I’m concerned that I may not be doing things properly. I love the plugin (it does exactly what I want), and I’m going to be using it fairly extensively, so any light you can shed on the above is greatly appreciated.
@Ranazar ~ I would be interested to know what you are using for your Category structure. I’m using the current version of the plugin with no modifications, and I’m not having any problems. Are you using a Category Base, or no? Without a link to your website, it is difficult to even begin to know what the problem is, but I’d like to fix it for other users, if possible.
It’s also possible that there is some unforseen difference between upgraded versions of 2.1.1 (which is what I have) and new installs. I have already seen this to be the case with Blogroll issues.
Any chance you can provide me with the output links that were “Borked?”
Thanks!
When I click on “Activate” to activate the plugin, I’m met with a blank page (whereas normally I’d be taken back to the Plugins page and shown the “Plugin Activated” message). Just for reference, the URL for the blank page is “http://localhost/changelog_prd/wp-admin/plugins.php?action=activate&plugin=collapsing_categories_wp21.php&_wpnonce=08623318dc”
After that, if I trying going back to the site (http://localhost/changelog_prd) or to any other link in the site, I’m met with a blank page. It looks like the PHP code is failing somewhere before it begins to output any HTML. If I delete the files from the plugin directory, things to back to normal.
So it doesn’t look like it’s a category structure issue. As I wrote this, I tried activating this plugin with a vanilla 2.1 Wordpress without K2, and with the default categories that come with Wordpress (Uncategorized and Blogroll). Still borked.
Let me know if you need anything else.
Huh! Well, I’ll be damned. Try deleting the entire thing: the Collapsing_Categories_WP21.php file and the col_cats folder and everything in it. Redownload the Widget again and try it again. That’s a weird one. I just did the whole thing over again on this blog and it worked fine. . .
Hi, I downloaded collapsing_categories_wp21.zip and found there are duplicated “(” in line 67
And is it possible to add an option to NOT show the empty category (like the default category “links” and “Uncategorized”, you can see my blog.
hi, i’ve the same problem with dennys.
after i’m delete the second “(” in line 67 the plugin can be activate.
but i have had the german version of wp, i cant find any widget to configure the plugin.
what can i do?
with best regards
klecks
@Dennys, @ Klecks: sorry about the delay. Please try redownloading the .zip version of the plugin and see if it works now.
@Klecks: I’m not sure I understand the second part of your problem, but try again and if it doesn’t work, could you be more descriptive? Thanks!
@Dennys: I imagine that is possible, yes. When I get a bit of time to do it, I’ll try to make that change for you. Thanks for the suggestion!
Hi,
The zipped file now only has the readme.txt file in there. Can you re-upload?
http://www.eringoblog.net/
Oos. I don’t know what just happened there. I installed the plugin, and I’m now getting this error message:
Fatal error: Cannot redeclare widget_collapsing_categories_init() (previously declared in /home/enappe27/public_html/eringoblog-net/wp-content/plugins/collapsing_categories.php:40) in /home/enappe27/public_html/eringoblog-net/wp-content/plugins/collapsing_categories/collapsing_categories.php on line 38
Help!
Did you download both versions, or something? I would just delete all the Collapsing Categories stuff and start over.
Never mind about that…I fixed it, but the widget doesn’t seem to be working.
OK, what seems to be happening?
Well, I first edited my categories to create category parents, then re-installed the widget. It’s appearing in my sidebar, but the categories are appearing exactly as they did before I installed the widget (except for the “powered by collapsing categories widget link at the bottom).
OK, two questions:
1. Which version did you download? For 2.0 or 2.1? Zip or Rar?
2. Are you sure about the hierarchy?
I suspect you’ve got the 2.1 version installed, but that’s just a hunch. It would explain why you’re not getting any parent categories, because that’s the primary difference between the two plugins and the loop wouldn’t work for 2.0.
I’d say that, if you’re certain that “category X is the child of category Y,” then you’ve probably downloaded the wrong version and should delete everything (again, sorry!) and download the 2.0 version.
I *thought* I downloaded the 2.0 version. I definitely downloaded Zip. But I’ll try again and see what happens!
Still not working. Is it possible that it won’t work w/this theme? (3K2)
Well, I’d hate to give you even more of a headache, but I’m thinking that there might be some other plugin that is affecting it. I’m noticing that all the link titles are coming up with “View all posts filed under Catholicism-WOW!” or whatever. That’s definitely not something that’s written into my code. You might want to disable all your plugins except this one and try again?
Plugins. They’re supposed to make life easier. . . .
Sigh. Thanks for your help, but I think I’m going to give up for the time being. I’ve spent too much time on this today.
Hi,
I downloaded the WP2.1 version and also had the extra bracket problem above downloaded from the .rar file. I also downloaded the .zip which was pretty much empty. But now I have it working.
If I wanted to change the sidebar manually, what would I need to do to add this collapsing utility - which BTW is exactly what I am looking for, thanks! I had previously made a number of customizations to the sidebar, and I don’t know how to get those working once I use widgets.
Hmm. . . so, you want a non-Widget version of the Collapsing Categories plugin? You probably only need to change the names of some of the functions, I imagine. If you’re familiar with PHP, I’d say check out the support site at WordPress and lookup how to make a plugin. The Widget thing is not that different, except that it uses keywords germane to the Widget scheme.
I gotta fix that stupid ZIP file. I’m too freakin’ busy for my own good and this Widget is surprising the heck out of me by being as popular as it is. . . .
hi!
i m trying to set this menu.but i can’t yet.
first i upload and activeted plugin.and then i goto presentation page but i cant see “Sidebar Widget”
what must i do about next step?. my catogory output on sidebar.php…must i add any code on this page?pls help me…thanks alot
[...] Collapsing Categories [...]
Hmm, looks like the 2.1 zip only has readme.txt inside. Did you take it down for a bit? This is exactly the plugin i’ve been looking for, looking forward to having it up and running
@David ~ OK, try again. Sorry about that!
Hmmm, Parse error on line 67. Seems that Denny and Klecks had the same problem. They didn’t post anything after, so I guess they figured it out. I’ll try that.
Oh yeah, forgot I don’t know shit about code. Might need a little help with this one. Thanks Thomas.
@David ~ the ZIP version is exactly the same as the RAR version, which has been working fine, as far as I know. Could you give me the exact error message? I’ve looked at the main php file and there’s nothing wrong that I can see. . . .
When I click the activate button, I get:
Parse error: parse error, unexpected ‘{’ in /home/content/a/g/o/agoodtycoon/html/wp/wp-content/plugins/collapsing_categories_wp21.php on line 67
I’m getting the same error as David…any ideas?
Read the earlier post by Denny and edited out the double ( bracket on line 67. Works fine now. Thanks for the widget.
[...] upgraded my blog because there just isn’t any way to make sure that my JavaScript Animated Collapsing Categories Widget will work the way I intended to make it work. Well, by and large, things are great. I [...]
The (( problem on line 67 is not yet resolved.
My main catagory ‘News’ is empty and my subcat ‘productnews’ holds 1 entry…
cat News shows [+] News (0) and opening gives productnews (1). How does the reader know to open the News for reading subcats.
How to get the total of ALL (sub)subcats listed in the main cat: [+] News (1)
@Johan ~ Hmm. . . That would be a good choice, actually, but I’ve not implemented it yet. As I recall (it’s been a while since I’ve looked at the code) there is a function that first creates an array of the different categories, in order by their inheritence. I suppose if I were to develop something, I’d start there first.
If you attempt it your self, I’d be glad to post the update here with credit given to you. Or you could branch. Up to you.
Thank you for writing this widget - it’s just what I was looking for. I’m running Wordpress 2.1.3, and the 2.1 version of your widget. A few notes about some problems I had setting it up:
1. Activating the plugin immediately borked Wordpress (all pages returned blank). As previous commenters have said, I had to manually edit collapsing_categories_wp21.php and remove one of the duplicate (s on line 67. After removing the ( I could activate the plugin and add it to my sidebar widgets.
ORIGINAL LINE 67: if(($item['link_count']
Rats. I included the line 67 code, which cut off my comment. I’ll repost my entire comment again (minus the code) and you can delete this comment and the cut-off one before it. Sorry.
Thank you for writing this widget - it’s just what I was looking for. I’m running Wordpress 2.1.3, and the 2.1 version of your widget. A few notes about some problems I had setting it up:
1. Activating the plugin immediately borked Wordpress (all pages returned blank). As previous commenters have said, I had to manually edit collapsing_categories_wp21.php and remove one of the duplicate (s on line 67. After removing the extra ( I could activate the plugin and add it to my sidebar widgets.
2. After I did that, I got the same list of categories that I had before (no plusses/minuses) in Firefox. In IE, there was a red-x icon next to each category. The solution to this was something you may want to clarify in your documentation. I had downloaded the .zip to my wp-content/plugins directory, then unzipped it there, which created a collapsing_categories_wp21 directory with everything inside. The plugin would activate when in there, but wouldn’t work. I imagine there’s some kind of hard-coded path in the code. I had to move everything up one level, so that collapsing_categories_wp21.php file and col_cats directory are now in my wp-content/plugins directory (rather than a subdirectory thereof).
I hope that was a clear enough explanation.
3. Finally, FYI to anyone who might encounter this: After making the above fixes, I needed to do a forced page reload (holding shift while clicking reload) to get the collapsing to work in Firefox. Simply clicking reload didn’t do the trick.
Thanks again!
@Kate ~ OK! I finally found a few moments of free time when I had access to stuff and FINALLY fixed this crappy error message! Funny thing, though: you must have JUST missed the corrected file, because I put it up there like maybe an hour ago.
You’re right, though: I should probably redefine that portion of the directions. Thanks!
This is merely a kudos. I’d been trying to convince myself to come up with the time to figure something like this out for ages - and found your lovely lovely plugin instead.
Thank you.
@KeiSolo: Hey, all comments are welcome on this blog, most especially those that are “merely a kudos!” I’m glad you like the plugin, thanks a bunch for the support!
I am completely lost with this. I installed it, activated it, but when I got to presentation it does not show me “Sidebar Widget” help someone?
Hello,
I found this tonight after I downloaded the new 2.2 Wordpress. Kudos BTW. Plugin looks nice. Since I didn’t use this with 2.1 I’m not sure if I would have gotten the error below.
This shows in the sidebar but just above the the created cat list.
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
SELECT * FROM wp_categories WHERE cat_ID =
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
SELECT * FROM wp_categories WHERE cat_ID =
The menu, although, showing and collapsed and expanded, had a couple blank category spaces but none were missing. I double-checked this. It was just an additional place for one but nothing there. Any ideas?
Regards, Veg
Oh, boy. . .
Well, a couple things cross my mind. One, that you’re using a newer version of PHP that isn’t as forgiving with the queries as 4.x. Two, that there is something that has changed about the way that WordPress is expecting queries in the newer version that makes my plugin incompatible, which wouldn’t surprise me in the least.
I dunno, it’s a brave new world, and I have not as yet designed to match the 2.2 framework.
Yes. I believe I am using PHP5 but considering that Wordpress changed the way categories are handled that may likely be it. I was using Dtree before visiting your site and it was having troubles as well. Feeling brave enough to tackle 2.2? : D
WordPress has not changed the way Categories are handled, yet. They were planning on adding “tagging” to this release, but they weren’t happy with it, so they rolled that back until 2.3.
The error you are encountering is most likely caused by MySQL5.x (sorry, I mistyped in the last response!). MySQL5.x is much more type-rigid than previous version of MySQL, so if you try to use a number as a text string or vice versa, it’ll bork on you. The problem may well be that I’m using a query that’s trying to do things that MySQL5.x doesn’t want to do. To be honest, I installed MySQL5.1 on a server once and got so pissed off at the inflexibility, I went right back to an older version and said the hell with it.
As for tackling WP2.2 and the tagging of WP2.3, yes, I’m going to need to find time to crack it all open and figure out how it works. Right now, I’m a bit at a loss for time, though.
Right on. Well, I understand that this is a labor of love to work on these projects and spare time is sometimes hard to come by. Hopefully when you revisit the plugin a solution will present itself. If not or not soon I still offer my compliments to its creation.
well I was able to get it to work, problem is it won’t take my sub sub sub categories.
ex. /category/subcategory *this works*
now.. /category/sub/sub/sub/
it doesn’t.
Instead it takes the name of the sub category and places it next to “/category/”
example. Let say one of them was : “/category/music/genre/artist”
on the menu it would pick it up and show “artist” but when I click artist , it does “/category/artist” such link does not exist. When the link to “artist” should read “/category/music/genre/artist”
Hi, Awesome plugin!
2 questions…
1.i have a Category-sub-sub Strtucture and would like the first sub automaticly collapsed or add collapsing support to the last sub only. how do i do that??
2. It displays my blogroll Category, even though i dont use it and if you click on it it gives me a 404 cause it links to myblog,com//blogroll
If any of you know how to work around these i would be very grateful
@leander ~ Thanks for the compliments! As to your questions, the second one is easy, the first is more difficult:
The problem you’re having is likely that you’re using the version of this plugin built for 2.0 on a blog built on 2.1. I had to edit the plugin to work with 2.1’s link categories.
As for question number one, boy, that’s a doozie. You’d probably have to play around with the JavaScript quite a bit to get the type of functionality you want. You mean you want the first subcategory to just not be visible at all? That’s a bit strange, why not just skip over it?
I can’t believe how fast you answered…
hehe better service than any company
hmm im using wordpress 2.1.1 should i upgrade in order to get rid of the blogroll dilema?
as for the 1st question i just want the wirst subcategorie (not the second) collapsed from default.. or having the option to collapse only for sub-sub categories Any will do, i hope this clarifies the questions,
thanks again for coding this awesome plugin can’t wait to implement it.
leander
Yeah, you caught me on a Friday!
You should be using the version of the plugin that is written for 2.1, not the one that’s written for 2.0.
As for collapsing: you want the first sub to automatically collapse, but the sub-sub not to collapse. Got it. OK, well the function you’re going to want to look into if you want to make this switch would be init(). Right now, it simply searches for any UL below the category with the “top_level” ID and sets it “display=’none’;”.
I didn’t feel the need to go through any great lengths to traverse the DOM, but in your case, you’d need to make it intelligently determine the depth and stop it from auto-collapsing. The good news is: you wouldn’t need to do anything special to make the animation work after that (assuming you still wanted sub-sub categories to collapse on user-request).
Hope that helps!
oh i see i downloaded the wrong version… will try the other one now
ok sorry to bother again
and thank you again for replying…
so i downloaded the other version which works better! (the link to blogroll is set correct)
but as i dont use the blogroll feature i still get 404. I’m considering to start using it just to use this widget…
as to the other concern you got my concern right. As i’m not really a coder i am wondering if it would be easier for me to implement your plugin only to subcategories. (same idea as before categories and subcategories shown, just subcategories have the “+” sign and can be folded)
i tried to find a clue from your former description and found a line called init() but i didn’t know what to put i am new to this php design i guess thats why i’m using widgets.
anyhow i’d like to thank you for your help,
leander
ok i worked around the 404 i had to use a different permalink structure so this one seems to be solved if you have any idea how to do the other one i’d be happy but i’ll think it’ll work for now thank you so much for your support
leander
I seem to be having troubles similar to leander.
The categories appear and collapse properly, but I only get “Not Found” notices when I click on the links. The URLs are directing me to “http://www.elephantinthecorner.com/category/CATEGORYNAME”, and I think I’m not properly set up for that permalink-wise.
Is there a way to get the URLs to direct to category ID numbers?
I have the same problem as jyhill. The Permalinks are not right and I get “Not Found”. What do I need in order to make them the same as the normal categories?
Hi, how could I use this without the widget stuff? just the php call like regular plugins?
I dont use widgets, thats why I want to use directly the plugin.
@ jyhill, @Zohar: it is a limitation of this plugin that you need to have categories begin with that /category/ prefix in order for them to work because this is the default setting in WordPress.
@Lasloo: You could certainly strip off the Widget-style stuff and use this as a conventional plugin. I just didn’t create it that way. The good news is: I did not deviate from the basic “how to create a widget” model, an example of which is the Google Search Widget that comes with the Widgets plugin. So, it should be fairly easy to reverse-engineer it. A word of caution, however: Widgets are built in to WP2.2 natively, so there is a limited advantage to stripping the plugin out of the Widget shell.
Just wanted to stop by and say great widget…my only issue would be that I’d like the ability to exclude my links categories from showing up in the list.
@Karura ~ You are using the wrong version of the plugin, there, mate! You want to delete that and download the one for WP 2.2!
Thanks, should have known to check for updates…*goes to download*
First off: Great plugin!
I have a grip of questions, but I’ll pick the top two;
1 - Will you add an RSS image option?
2 - As per Kaura’s part of this here thread…is there 2.2 plugin? Coulda swore the 2.1 version was the latest. Is there an updates page/feed? (Cuz if you add the RSS bit, I mos definitely want it!)
@MikeM: I’m not entirely sure what you mean by an RSS option, could you be more specific about what you want? Sounds intriguing.
As for a 2.2 option, I haven’t tried it with 2.2 and I don’t know much about it’s compatibility. I’ve been too tied up in other matters to get to it, even though I’m planning on working up a development environment to work on 2.3.
I was under the impression that the switch they’d planned on making to tag-based as opposed to category-based organization hadn’t happened yet. I think they tried and decided against it until 2.3. If that’s the case, I don’t know what would be preventing it from working with 2.2. Have you actually tried it, or no?
Yes, I have 2.2, and I’m using the 2.1 plugin.
As for the RSS: If you were to edit t