Extension talk:CategoryTree/Archive 01

Add discussion
Active discussions
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).


Sort Order

It would be nice to add an option to sort articles by first letter in article name, or to bypass sorting by surname in articles about people. --Sasa Stefanovic 15:49, 1 September 2006 (UTC)

"sorting by surname" is actually sorting by the sort key that is explicitely provided when the page is placed in the category. That's what category listings are sorted by. I'll think about adding sort options for the <category> tag and the special page - the view on the category pages will probably stay as it is. -- Duesentrieb 21:35, 1 September 2006 (UTC)
Yes, you know what i mean. And, when will be that option included ? --Sasa Stefanovic 21:54, 3 September 2006 (UTC)
Some time. Including the option isn't hard, but getting it right with caching is. -- Duesentrieb 23:27, 3 September 2006 (UTC)

After installing this excellent extension this was actually the first thing I wanted to be improved. I see it's already worked on it.

--Reinhard Brandstädter 08:45, 1 December 2006 (UTC)

I started using CategoryTree yesterday and I love it... But, there's one thing that I try to accomplish... If I have a category with two subcategories and three articles... Can I somehow disable the fact that the subcategories are sorted at the top?... I would rather have both the subcategories and articles sorted togheter...
/Jesper 4 January 2007

CategoryTree: Finnish translation

Hi, Duesentrieb. Kooma translated the new MediaWiki messages in Finnish Wikipedia and I made a php file from them. Should I paste this file to User:Duesentrieb/CategoryTree-fi, so that translations would be included into MediaWiki? --Hartz 13:49, 1 September 2006 (UTC) copied from my talk page -- 17:59, 1 September 2006 (UTC)

Cool! Hm, the language files under User:Duesentrieb/CategoryTree-xx are for the external tool, that's a bit different... please look at the i18n files in the repository and make a patch/file from that. -- Duesentrieb 17:58, 1 September 2006 (UTC)

Suggestions for CategoryTree

First, congratulations for your integration into MediaWiki of CategoryTree, it's very useful and funny :-) ! In the french Village Pump, somebody has proposed to place an option in the preferences to choose between the alphabetical list and the tree. Else I request a new message to differentiate the message nothing found when no subcategory is founded or no parent category is founded, so we could write no parent category founded and no subcategory founded. I ask this here but perhaps it would be in a better place on bugzilla. Best Regards and Congratulations :) ~ Seb35 16:52, 1 September 2006 (UTC) copied from my talk page -- 17:59, 1 September 2006 (UTC)

a new user option would be nice i guess, but afaik there's no clean way for extensions to put something into on preferences page. Maybe the selection could just "stick" once a user has made it? I'll think of something, not sure what yet.
An extra message for the parent categories also needs at least a third message for "no subcategory or page", in case pages are included in the tree. On the other hand, parent categories are shown only on the special page - which is kind of redundant anyway. Maybe i'll turn it off in the future.
I'll look into getting CategoryTree set up as a "product" in Bugzilla. -- Duesentrieb 18:09, 1 September 2006 (UTC)
Thanks for your quick answer. For the option (we haven't see that it use cookies), someones purposed that because they don't like the change, the main reason is that it make a big column for some category w:fr:Catégorie:Parti_politique_par_pays (as your next note says), and a second small reason is that it don't work on their config (JavaScript?). Else fr:Utilisateur:Lgd who work in accessibility for Wikipedia says interesting things about this, I asked him to tell here his point of view. ~ Seb35 07:49, 2 September 2006 (UTC)

I have written a "unified" category view which looks just like the traditional three column display but lets you expand each subcategory as a tree. It's enabled here on meta now, see Category:MediaWiki for example. I guess that will become the preferred mode in the future. -- Duesentrieb 12:45, 2 September 2006 (UTC)

Is there anywhere that can be downloaded? --Paul Barkley 15:16, 25 September 2006 (UTC)

This extension is great. Here are a few more ideas:

  • Alternate Toggle Icon Is there a way to replace the [+] and [-] toggles with image icons? If so, how and where do I do it?
  • Category Toggle It would be nice if there was an option argument that turned the label of each category into an expand/collapse toggle instead of a link to the category page.
  • Dead End Notification In response to a request below about the possibility to remove the + before a category with no subcategories/pages, Duesentrieb responded that to do so would require a separate query, slowing the system. On the other hand, a reader clicking on a + toggle only to find that there were no further subcategories/pages also slows the system (in the reader’s experience). It might be worthwhile to add this type of functionality, but have it included as either a mode or another option so that editors could decide whether the delay is acceptable for their applications.
  • Population Notification Similar to Dead End Notification, above. It would be helpful for a reader to be able to see whether a category includes thousands of pages or just a few without having to toggle expand and collapse to find out. It would be awesome to be able to display page counts next to the category labels, perhaps by integrating DynamicPageList code.
  • Alternate Expand/Collapse Fonts It would be helpful for my readers if the root labels of expanded lists were highlighted. I noticed that making the text bold is on the General ToDo list. Perhaps it is easier and more flexible to add a CSS class to the labels and let the rest of us alter the font appropriately in the css file.
  • Table Header I could use the opportunity to put a header at the top of the table that CategoryTree creates. (I know. I know. I can do this by creating my own table and putting CategoryTree statements inside. In my application, though, I transclude CategoryTree in a template and the calling page does not always create a CategoryTree result. If I put CategoryTree statements inside a table and the calling page doesn’t pass any categories, the result is an empty box.)

Thanks, Furboy 22:24, 6 December 2007 (UTC)

General ToDo

  • Note to self: make a "unified" view: "traditional" three column view, but with "expandable" subcategory entries. -- Duesentrieb 21:36, 1 September 2006 (UTC)
  • "no subcategories" vs. "no pages" vs. "nothing"
  • Make top level subcats bold?
  • Hide [+] toggels if no JS?
  • use global nojs switch instead of notree?
  • add an attribute to categories without children, when loaded.
  • Make "root only" mode for tag.

(short reminders for myself -- Duesentrieb 11:55, 4 September 2006 (UTC))


Hi. Wir hatten ja heute schonmal im Chat über die +-Zeichen vor Kategoriebäumen gesprochen und die Möglichkeit, diese auszublenden. Ich hab mir das ganze jetzt mal im de:Lynx (Browser) angeschaut und muss feststellen, daß das da doch recht unschön und verwirrend ist, wenn ein Link angezeigt wird, der aber generisch eine Fehlermeldung auswirft: de:Bild:Cattree in lynx.jpg. Ich grüble schon die ganze Zeit, wie man es vielleicht doch verstecken kann. --Gnu1742 19:31, 2. Sep 2006 (CEST) Ich musste mit schmunzeln feststellen, daß Lynx im Fehlerfall 'Obacht' schreit;-))


Can this extension be used in the sidebar? There's similar work going on with the DPL2 extension here: m:Talk:DynamicPageList2#Add Format Option for display in sidebar

20:49, 2 September 2006 (UTC)

The external tool (see User:Duesentrieb/CategoryTree) can. Maybe I'll add this to the MediaWiki extension - but sadly, different browsers expect slightly different things in the sidebar (especially ragarding the target-attribute of links). This makes it a bit tricky with caching and all that. -- Duesentrieb 21:53, 3 September 2006 (UTC)

Some discussion at en-Wikipedia

See Wikipedia:Wikipedia:Village pump (technical)#Show as a tree / Show as a list in Catgegories. In particular, the comment here: "One potential problem is that people who click on the "+" sign and get the "nothing found" result, might think that is the end of the road: no articles there. Of course, it really means that there are just no subcategories. But will new users realise they need to click on the category link to see the articles inside the category?", and the comment by DuncanHill asking for the ability to chose which display he can use. Some further comments, but not much discussion yet, at Wikipedia:Wikipedia talk:Categorization#Show as a tree / Show as a list. It would be nice if someone from meta could come over to the en-Wikipedia, as not everyone there will be aware of the discussions at Meta. Thanks. - Carcharoth 11:25, 3 September 2006 (UTC)

Update: the "nothing found" label has now changed to "no subcategories" (on en-Wikipedia at least). Thanks for this. On Meta the label still says "nothing found". Haven't checked the other WikiMedia projects. Carcharoth 20:52, 3 September 2006 (UTC)
Update: Meta "nothing found" label changed to "no subcategories" (note - I am just recording what I see happen. I'm not implementing any of this - I don't know my Mediawiki from my Wikimedia! :-)) Carcharoth 12:22, 6 September 2006 (UTC)
Better yet, if no subcategories exist, hide the "[+]" control. Eep² 13:35, 20 July 2007 (UTC)

Fatal error?

Any idea what is wrong when I get this error-message?

Fatal error: Undefined class name 'xml' in ../wiki/extensions/CategoryTree/CategoryTreeFunctions.php on line 54

--4 September 2006

Which wiki? your own? Hm, what version of MediaWiki are you using? CategoryTree is currently for 1.8alpha only. I don't think it'll run with 1.7, as I had to change some bits in the code code to make it work. -- Duesentrieb 17:29, 4 September 2006 (UTC)
Ah, that explains a lot. Thanx. --5 September 2006


I have this extension running on my wiki, but when you are looking at a category tree and change any of the settings then press the button, or enter, to have them take effect it neglects to inculde the title=Special:CategoryTree& part of the url. Does anyone know where would I add that? I've been looking around a little and have yet to find it. For instance, instead of showing


Clicking the button shows


--Paul Barkley 16:45, 21 September 2006 (UTC)

Quick fix (horrible hack!)

  • Edit CategoryTreePage.php
  • Find the following line

$form .= wfOpenElement( 'form', array( 'name' => 'categorytree', 'method' => 'get', 'action' => $thisTitle->getLocalUrl() ) );

  • After this line, add the following line

$form .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'title', 'id' => 'title', 'value' => 'Special:CategoryTree' ) ) . ' ';

-- Ricmelia 09:18, 20 October 2006 (UTC)

Thanks, hack or not it worked perfectly. --Paul Barkley 20:16, 24 October 2006 (UTC)
Still works fine with MediaWiki v1.10.0 --WIKImaniac 15:24, 22 August 2007 (UTC)

Blank Page when enabled.

I am running Mediawiki 1.8.1 and when I enable this extension My site goes blank. I turned off all other extensions to test if it was some type of incompatibility, but that didn't work either. --13 October 2006

Check if after require_once("extensions/CategoryTree/CategoryTree.php") have a ; in localsettings.php like bellow:
--kostas1972 17:22, 15 October 2006 (UTC)
Yes the ; is there.
This is my configuration:
MediaWiki: 1.8.1
PHP: 5.0.4 (apache2handler)
MySQL: 4.1.20
so check if this line or any other line similar (for enableing extensions)
is placed at the bottom of localsettings.php for example if extension :::whoisonline be placed on top or near top everything goes white ... when placed at bottom everything its ok.This happen because the extensions not loading at the right time and things mixed up, most common is to place them at bottom exept one or two of them.
TRY change this orders .I cant find any other explanation...if not working :::try redownload categorytree.
--kostas1972 File:Gre.gif 22:21, 16 October 2006 (UTC)
OK, I got it working but I cannot collapse the tree. i get a javascript error: categoryTreeCollapseNode is not defined.
the script working fine if you download from svn!i had notice that the tgz. file is full of errors try redownload the script delete all files and copy the newfiles in extensions/CategoryTree/ it sould work with 1.8.2 and 1.8.1
i have the same php and apache versions on fedora core4 now working excellent ... my problems stoped... see bellow my other post for details about svn and packed tgz folder if you can't download from there go here is my ftp and download my own script working on 1.8.1 and 1.8.2 i copy it there for you(en language only).I can't do anything else.And Don't forget to inform us here about the results...
--kostas1972 17:52, 17 October 2006 (UTC)
  • Success! It works after I download your files. --20 October 2006

Peter Blaise says: Me, too - a blank page. What did you do to resolve the initial blank page syndrome to get to the javascript error? After re-downloading from the raw, non-zip files, I managed to get:

 "mywikiname" has a problem
 Sorry! The site is experiencing technical difficulties.
 Try waiting a few minutes and reloading.
 (Can't access the database serer: Access denied 
 for user 'wikiuser'@'localhost; (using password:YES)

I had to go back to an earlier version of LocalSettings.php (I make and keep a copy before each change), and I cannot seem to install Extension:CategoryTree and have it work - I always get the blank screen syndrome. My resources: I have direct access to my Microsoft Windows XP Pro server, with:

MediaWiki: 1.10.0 
PHP: 5.2.2 (apache2handler) 
MySQL: 5.0.41-community-nt 
 Special pages 
 LastUserLogin (version 1.0.6) 
  Displays the last time a user logged in
  Justin G. Cramer, Danila Ulyanov, Thomas Klein 
Parser hooks 
 DynamicPageList2 (version 1.2.1) 
  based on DynamicPageList, featuring many improvements 
  IlyaHaykinson, Amgine,Unendlich, Cyril Dangerville,Algorithmix 
 Subpage List 2 
  automaticaly creates a list of the subpages of a page 
  Martin Schallnahs, Rob Church 
Extension functions 
 wfLastUserLogin, wfUpdateUserTouched, wfDynamicPageList3, 
 wfDynamicPageList2 and efSubpageList 
Parser extension tags 
 <dpl>, <section>, <subpages> and <pre> 
Parser function hooks 
 dpl, int, ns, urlencode, lcfirst, ucfirst, lc, uc, 
 localurl, localurle, fullurl, fullurle, formatnum, 
 grammar, plural, numberofpages, numberofusers, 
 numberofarticles, numberoffiles, numberofadmins, 
 numberofedits, language, padleft, padright, 
 anchorencode, special and defaultsort 

 Hook name Subscribed by 
 LanguageGetMagic wfDynamicPageList3_Magic 
 LoadAllMessages wfDynamicPageListSPloadMessages 
 visited from
Retrieved from "http://etc00322/ustdedwiki/index.php/Special:Version"

Thanks -- Peter Blaise peterblaise 17:58, 11 July 2007 (UTC)

Bad target for sajax_do_call: not a function or object: undefined

when press + to open subcategories i get this error any idea? please help.

bad target for sajax_do_call: not a function or object: undefined

--kostas1972 17:53, 17 October 2006 (UTC)

PROBLEM SOLVED : downloaded again the files from SVN this time and worked
the link inside wediawiki-extensions/categorytree-extension provides this link :(download area with bundled version ->notworking) provides a zip file with older(or broken) files ... someone must check and fix this.
Download a working version from svn here:
I also made a Greek (el) translation for CategoryTree-extension available here untill User Duesentrieb post it in svn
and a (el) translation
CategoryTree-external tool el be carefull this is the external tool not extension translation
--kostas1972 17:53, 17 October 2006 (UTC)
I was getting this problem too. Then I upgraded to 1.8.1 and now the extension doesnt show at all.
you mast update your localsettings.php ... put somewere at the end the following:
$wgUseAjax = true;
--kostas1972 17:53, 17 October 2006 (UTC)
I have downloaded the files from SVN and am still getting
target for sajax_do_call: not a function or object: undefined
I would really like to use this extension - how do I get it to work???--Magick 22:35, 18 October 2006 (UTC)
What version is your wiki? 1.8.1 and 1.8.2 is supported and none bellow.
Have you carefully replace all files inside extensions/Categorytree/ with the new files?
Try download this packet from Myftp -first delete the folder categorytree- inside extensions folder(of your wiki) jast to be sure that the new one which downloaded from me will make a clean install
I followed this steps my self and worked. see what i did:
I had the broken categorytree in wiki1.8.1 so i deside to upgrade to 1.8.2 then thought that is better to make a full install so i placed a second folder with wiki1.8.2 in my server and made a full install with the same dbase i download the categorytree many times(notworking on 1.8.2) untill i find that svn had the correct and newer files (from the first time worked) to my wiki1.8.2, my next step was to find if the tree will work on the old 1.8.1(broken tree) so i delete oldfolder-categorytree from 1.8.1 and simply copy the new-svn-working-categorytree folder from 1.8.2 ....working after all these days... working ... so easy ! now i have two versions of wiki 1.8.1 and 1.8.2 working in parallel(i left there for severall comparisons)with the same bd , settings ,extensions with the same contentpages(of same bd}and ofcourse the categorytree Working both....look your selfwiki1.8.1 and wiki i also keep and 1.7 version to compare versions for a wile....later i deside to upload to myftp for people here till admins fix this mixup with these version.. i belive that's the problem with errors.
Ihave apache 2.0.54 ,php 5.0.4 on fedora core4 i was geting this error untill find this version of gategorytree in svn(see link adove).
Also make sure that you cleaned your browser's cache and reload page to see results and that all extension entries in localsettings.php placed at the bottom jast before ?>
kostas1972 13:57, 19 October 2006 (UTC)
Worked for me after clearing cashe. Great extension. Thank you. --19 October 2006

All Pages options for Subcategory listing

Is there a way to enable the all pages option on category pages for subcategory children? I.E I have a number of documents seperated by month, and a category for each month. Each month category, in turn, is a subcategory of the year category, which is a subcategory of the main 'parent' directory.

When pressing the [+] beside the first child (the year) a reader will see the month, but when pressing the [+] next to month, the reader is shown "no subcategories" it would be benificial, at least in my case, to be able to display the contents of each month on the 'parent' category page. I know this can be done when using the <categorytree> tag, but is there a way to do it for the dynamically configured CategoryTrees? 14:54, 19 October 2006 (UTC)

i think that is no option i looked for a way to hack this but no lack (iam not so an expert) i suggest (if this help) to do this:
redirect the category you are intersted in to a new page and add to this page a categorytree tag with mode=all and any other options you need inside so you get the result .. the category goes to the page automatic and list all content after press + child by child.if want the hall site to dehave this way link all(hard?)categories to a parrent category and then redirect to....page. in your case things are easy go to the year cat and redirect to somepage,inside somepage now place the categorytree tag with the option mode=all .... every user hits cat year will view directly the somepage with cats-subs-pages and so on...beside this you will have the option to leave other categories in the default display!
An other thought >
You can use the DynamicPageList extension or Dynamic Article List(shows the newer articles} you can build nice listings in tables for months, years ... in scrollable tables eith css you will have something like calendar with articles, what do you think is this feasible??
#REDIRECT [[somepage]]
kostas1972 21:51, 19 October 2006 (UTC)
I tried the #REDIRECT and using the categorytree tag on the redirect page, but I still get a 'no subcategories' displayed when clicking the [+]. I can add the categorytree tag to the parent category to list everything that I want it to do. I'm not saving myself any labor, but I'm not really causing myself any labor either.
I'll have to take a look at those extensions you've listed and see what I can do with them, if maybe they will do something like what I'm wanting. Thanks! 14:06, 20 October 2006 (UTC)
<categorytree mode=all>somecategory</categorytree> that is the format to display articles and subcategories in a categorytee....I suggested the redirection of category to a newpage as this will not display twice the cats and sub cats in a category page..also can put the tag in any page to avoid redirections and guide users there.
The other extensions i mentioned is not exactly what you want but can enanche your articles listings...
Hope that this helped you...have a nice day.
kostas1972 17:19, 20 October 2006 (UTC)

My hack

  1. Locate where the CT_MODE_CATEGORIES is default parameter of a function, e.g.
    function efCategoryTreeAjaxWrapper( $category, $mode = CT_MODE_CATEGORIES ) {
  2. Replace by
    function efCategoryTreeAjaxWrapper( $category, $mode = CT_MODE_CATEGORIES ) {
  3. In efCategoryTreeParserHook function, replace
     else { $mode = CT_MODE_CATEGORIES; }
     else { $mode = CT_MODE_PAGES/*CT_MODE_CATEGORIES*/; }

--Iubito 17:08, 19 November 2006 (UTC)

Not sure if anyone is still looking for a way to have the ALL or PAGES mode by default on the dynamically created "Subcategories" pages. The above hack only changed the default mode of the categorytree tag to PAGES, but it did not change anything in the "Subcategories" pages. I think I've found a way to do it though. I'm in the middle of testing this to make sure nothing else is broken. Please let me know if anyone is still interested in this. Thanks
-- alex 10:48, 09 March 2007

Two wishes

I would like to have two features:

  • Remove the prefix "Category:" in tree. This is an easy one, isn't it?
  • Is it possible to remove the + before category with no subcategories/pages?

If these changes won't make it in your repository, can you tell me how to do it?

Thanks a lot, akw --23 October 2006

Hi - the "Category:" prefix should be hidden if you specified that you want only categories. At least I vaguely recall writing it that way :) If the tree also shows normal pages, it would be confusing to omit the Category:-prefix.
It is not pssible to remove the + beforehand - only after the "subtree" has been loaded (that would be a bit tricky, but doable - look into CategoryTree.js). To know in advance if there are pages/subcategories in a category means an additional database query for each category shown (i.e. n calls instead of 1 call, for every time you load a category view) . That would be too slow.
Regards -- Duesentrieb 14:18, 24 October 2006 (UTC)
I don't think it is confusing to omit the category prefix everywhere, because every category has a [+] or [-] prefix. So it is always easy to distinguish a category from a normal page. JePe 10:49, 29 October 2006 (UTC)
I also wanted to remove the "Category:" namespace prefix from the "all" listing. This can be done by changing lines 289 to 291 (orginal lines shown below):
#when showing only categories, omit namespace in label
if ( $mode == CT_MODE_CATEGORIES ) $label = htmlspecialchars( $title->getText() );
else $label = htmlspecialchars( $title->getPrefixedText() );
By removing the conditional and always calling getText() instead of getPrefixedText() you can always get the text without the namespace prefix. So the short of it is you end up with the following code replacing the above code with the following code:
#when showing only categories, omit namespace in label
#Roy's Hack: Always hide the category namespace label
$label = htmlspecialchars( $title->getText() );
--w:User:Imjustmatthew 13 November 2006

As of Revision 17863, it is now possible to suppress the namespace prefix using the option $wgCategoryTreeOmitNamespace = true; See bugzilla:8011. -- Duesentrieb 10:09, 23 November 2006 (UTC)

Now that a hack is no longer needed to remove the "Category:" namespace prefix, I am looking for a hack to "hack" a little more off the front end of my category names. In my application, each category is preceded by an uniformly formatted ID. Is it possible to replace the category text with a truncated copy of the text? If so, is it possible to evaluate the category text to determine if the leading characters meet a certain formatting criteria, and then make such a replacement? If so (going out on a limb here), how and where would I write the equivalent of the following SQL statement?
 SET category = Mid(category,17) WHERE category Like '(##) ## ## ## - *';
- Furboy 22:43, 6 December 2007 (UTC)

CategoryTree in the sidebar

I have made some css to load CategoryTree in the sidebar of Firefox. This is possible since every page has it's own class. The css strips everything from Special:CategoryTree except for the tree itself. It must be placed in User:XXX/monobook.css. For other languages than English the text "Special" must be changed to the right namespace-name.

body.page-Special_CategoryTree .firstHeading, 
body.page-Special_CategoryTree #jump-to-nav,
body.page-Special_CategoryTree p, 
body.page-Special_CategoryTree form, 
body.page-Special_CategoryTree .CategoryTreeParents,
body.page-Special_CategoryTree .portlet, 
body.page-Special_CategoryTree #footer,
body.page-Special_CategoryTree #siteSub
  { display:none !important; }
  { background:white; }
body.page-Special_CategoryTree #content 
  { margin:0; padding:0; border:none; background:white; }
body.page-Special_CategoryTree .CategoryTreeItem 
  { white-space:nowrap; }

Now you can load the following page and make a bookmark which loads it in the sidebar: w:en:Special:CategoryTree?target=Categories&mode=all
JePe 20:34, 28 October 2006 (UTC)

CategoryTree nur mit Tag benutzen

Hi Düsentrieb

Wie ist es möglich, CategoryTree nur mit dem -Tag zu benutzen, ohne dass gleich ALLE Kategorien mit dem Tool ge-'Tree'-t werden? Ich möchte nur selektiv Kategorien durch einen Tree darstellen, die Standardanzeige der verlinkten Kategorien jedoch nicht. Ist dies überhaupt möglich?


Gruss --BadBoy 22:37, 7 November 2006 (UTC)

Das auszuschalten ist zwar nicht vorgesehen, aber dennoch relativ einfach: In der Datei CategoryTree.php, setze ein "#" an den Anfang der folgenden Zeile, um sie zu deaktivieren:
  $wgHooks['ArticleFromTitle'][] = 'efCategoryTreeArticleFromTitle';
Dann sollten die Kategorieseiten wieder "normal" sein. -- Duesentrieb 20:54, 8 November 2006 (UTC)

Request Version number

First, Kudos for a cool extension. Is there a way to include a version number on the Special:Version page so that it is easy to make sure I am running the right one and see what other sites are using? Right now, I'm checking out the .php file, but may not always have access behind the scenes. Thanks. — MrDolomite | Talk 20:01, 9 November 2006 (UTC)

Hm, the only reliable way to do that would be automated version tags inserted by svn. That isn't enabled in the mediawiki repository. Sure, I could just write a version number into the name, but someone will sooner or later edit a line or two without updating that number. So it would be pretty worthless. -- Duesentrieb 22:53, 10 November 2006 (UTC)

Files list in Install Dox

Yet another 'Hooray!' here. I was trying to install this and the Dox tell you to move the CategoryTree directory into the *\extensions folder. Eh? What files and where do I get this directory? Go to the ReadMe and that is equally clear. Go to SVN and there are a bunch of files. ... take all of them? Yes, that's what I did but I am not sure I have the correct ones, on the correct version, and if they all go to build the directory.

A list of what should be in the directory would be a good starter. Even better would be to build a working directory and tar.gz it as a downloadable bundle.

thanks -- Slamlander 16:52, 16 November 2006 (UTC)

This question, and its answer, is the same for all MediaWiki extensions - it is probably explain in five places, all of which are obsure and hard to find :) But anyway, I see no point in repeating (and maintinaing!) the instructions for every extension.
The official place for extensions is [1], inofficial bundles are at [2]. Most extensions have their own directory, which should be placed inside the extensions folder. But it doesn't really matter where you put them, as long as you use the correct path to include the extension "main" file (CategoryTree.php in this case) in your LocalSettings.php. -- Duesentrieb 13:28, 22 November 2006 (UTC)

Expanded part in the category tree


If I have a hierarchy like

 - B
   - C

and I'm just reading page B it would be very nice if the pages below B are expanded when B is visible... Is there a possibility to do this with the current version?

thanks -- 23:23, 18 November 2006 (UTC)

What do you mean by "just reading" and by "visible"? Sorry, I don't understand your request. -- Duesentrieb 13:29, 22 November 2006 (UTC)
If page B is shown, the category tree will just show a
+ A as the whole tree should be available (<categorytree>A</category>).
But it will be nice if the user can see the children of page B as he's currently in that level:
- A
- B
+ C
(for example with <categorytree current-child="B">A</categorytree>)
--22 November 2006

Ah, OK - youwant to tell it to automatically expand down to a specific node. That'S tricky - first of all, I would have to determine the full path from the "root" to the "current child" (which takes several DB queries). Then I would have to immediately expand down to that child (which again takes several DB queries). In your example, this is not such a big problem, because B is directly under A, and there are only three nodes total. But for a general solution, this could become extremely expensive if used incorrectly.

I don't see a way to do this cleanly, sorry. -- Duesentrieb 10:29, 23 November 2006 (UTC)

Yes, there has to be a recursive question for the parent. This procedure can generate some JavaScript code (in my example expand(A);expand(B). For that I just see a little cost (just the number of parents). Perhaps I can gain some skill in PHP to do it by myself but do not bet on it ;)
-- 10:09, 28 November 2006 (UTC)

CategoryTree.css and CategoryTree.js wrong MIME-Type


We are using mediawiki 1.8.2 with Apache 2.0.54 and PHP 5.0.4, after installing CategoryTree and calling the Page, we got the message:

Error: The stylesheet http://wiki.MyDomain.net/extensions/CategoryTree/CategoryTree.css was not loaded because its MIME type, "text/html", is not "text/css".


Error: syntax error Source File: http://wiki.MyDomain.net/extensions/CategoryTree/CategoryTree.js Line: 1 Source Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Apparently the $wgScriptPath seems not to work (in the LocalSettings.php is $wgScriptPath = ""; because the wiki is installed in the root). Any suggestion? --20 November 2006

I'm pretty sure this problem is unrelated to the extension itself. The files are served directly by apache, not through mediawiki - so, if you see the wrong mime type, apache is giving the wrong mime type. Please try to enter the url directly into your browser and report what you see.
My guess is that apache is not serving the css and js files at all, but an (html) error page (probably a 404 or 500). I suspect this is due to rewrite rules you are using to have the wiki in the server's document root - you need exceptions to the rules for special directories, like /skins; For the CategoryTree extension to work, you need to make /extensions such an exception too. -- Duesentrieb 13:34, 22 November 2006 (UTC)
In short: You win! :) I put the 'extensions' into the RewriteRule an now it works as expected. Thank You! --22 November 2006

Collapsed by default?

When using the tag method, is there a way to show the tree collapsed by default? --Sanbeg 5 December 2006

I agree. This would be a very good thing to have. The Special Page has it about right. It has the topmost level expanded, but all the rest aren't. Anybody know how to best do this? --N0ctrnl 21:40, 14 November 2006 (UTC)

An onlyroot option has been added in rev:20385. @N0ctrnl: expanding one level is the default behavior. -- Duesentrieb 11:43, 13 March 2007 (UTC)

Default open depth

Would it be possible to specify how deeply the tree was initially open? It would be useful if the tree for a category coulb be made to list all of its subcategories and their subcategories; that is one level farther than is currently shown, as if every + was clicked. -Sanbeg 00:25, 5 December 2006 (UTC)


Problem with Firefox

I have a fresh installation MW 1.9.2 with categoryTree. It works fine with IE6.

Using Firefox (1.5x and I can open the +, it displays load (laden) and then nothing.

Firfox error console reports: "Fehler: uncaught exception: Die Erlaubnis für den Aufruf der Methode XMLHttpRequest.open wurde verweigert"
meaning "Error: uncaught exception: The permission to call the method XMLHttpRequest.open was not granted".

I do not use a short url. Any ideas? --GunterS 17:26, 26 February 2007 (UTC)

Some security policy seems to prevent the ajax call. No idea what it could be exactly. Do you have the same problem on other wikis, like wikipedia? Perhaps when using it with "ugly" URLs? -- Duesentrieb 00:34, 27 February 2007 (UTC)
Seems to be a problem with the pc-firewall. Accessing the wiki from a pc with a different configuration there is no problem. --GunterS 08:59, 31 March 2007 (UTC)

Working on category pages but not when included

After installing the extension it works on the category pages and on the special page but when I try to manually put it on a page clicking the (+) doesn't do anything. I'm using the following code:

<categorytree style="float:right; clear:right; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;" mode="all">Test1</categorytree>

I also tried:

<categorytree mode="all">Test1</categorytree>

--27 February 2007

Please check your JS error log and report what it sais. Also look at the HTML source and see if CategoryTree.js is included properly. This might be a problem with the skin. -- Duesentrieb 00:35, 27 February 2007 (UTC)

Good hint, looking at the HTML code of a page and comparing it with the special page I noticed the following entry missing:

<!-- Head Scripts -->
<script type="text/javascript" src="/testwiki/extensions/CategoryTree/CategoryTree.js"></script>
<script type="text/javascript"> 
 var categoryTreeCollapseMsg = "collapse"; 
 var categoryTreeExpandMsg = "expand"; 
 var categoryTreeLoadMsg = "load"; 
 var categoryTreeLoadingMsg = "loading"; 
 var categoryTreeNothingFoundMsg = "nothing found"; 
 var categoryTreeNoSubcategoriesMsg = "no subcategories"; 
 var categoryTreeNoPagesMsg = "no pages or subcategories"; 

Actually I use the default skin (Monobook) and also tried a couple of other skins - doesn't work on any of them. Any pointers where this JS code should be actually inserted? --27 February 2007

It seems like efCategoryTreeParserOutput is not being called when the page is rendered. efCategoryTreeParserOutput implements the OutputPageParserOutput hook - maybe another extension is interfereing with that hook (for example by not returning true from its hook function). Try including the CategoryTree extension before any other extension. And check that OutputPage.php contains the line wfRunHooks( 'OutputPageParserOutput', array( &$this, $parserOutput ) ); - if not, your installation is somehow broken, or quite old. What version of MediaWiki are you using? The last possibility I see would be that something is messing with the ParserOutput object, and the mCategoryTreeTag flag is lost. -- Duesentrieb 20:44, 27 February 2007 (UTC)
Thanks! It was another extension that messed with this hook. After I disabled it the category tree works perfectly fine... --27 February 2007

Sort Order Case Insensitiv

Would it be possible to sort categories case insensitiv? e.g.

SAP Batch

Today it is first SAP BW, which is not so nice. --GunterS 18:25, 1 March 2007 (UTC)

Show only root initially

I'd really like to have an option that makes the categorytree folded when first called. Ger Apeldoorn. 6 March 2007

done in rev:20385 -- Duesentrieb 11:41, 13 March 2007 (UTC)

Location of code that handles displaying the titles of the children?

Was wondering if anyone knew where in the categorytreefunctions.php the part where it handles the names of the children when you expand the tree? Reason is so I can edit the titles so they only show the last part of each title instead of the entire title, since the titles I use are seperated by colons and can get very long. It's not the $label area in renderNode section as it only handles the nodes being displayed first. Vince 13 March 2007

It is $label in the renderNode function: ajax() calls renderChildren(), which calls renderNode(). If you are not seeing the effects of your changes, there is probably a caching issue. Especially, look at $wgCategoryTreeHTTPCache and the calls to checkLastModified() and loadFromMemcached() in the ajax() function. -- Duesentrieb 11:08, 13 March 2007 (UTC)
Ah thank you for the quick response. You were right, it was just my browser cache showing what the old pages looked like in the tree. Vince 13 March 2007

Compatible with 1.9.3?

Is this extension compatible with 1.9.3? Just did a fresh install, loaded CategoryTree (the only extension), Special:Version shows it to be loading, but the inline function returns "Category foo not found" (foo being a real, present category) and using the form on Special:CategoryTree just kicks me out the main page.

The js wasn't being loaded into the head of the template (monobook) initially, but even after I manually inserted the js into the head of the template, the plugin does nothing.

  • MediaWiki: 1.9.3
  • PHP: 5.2.1 (cgi-fcgi)
  • MySQL: 5.0.24a-standard-log
  • CategoryTree r20410

TIA, -S --17 March 2007

Since the extension has been running in Wikipedia continuously since the days of 1.8alpha, I'm pretty confident it's compatible with all versions since. I have also used it with 1.9 myself. I don't know why you are having problems, sorry. -- Duesentrieb 14:09, 17 March 2007 (UTC)
Thanks for the quick reply. Do you have any pointer on where I should start troubleshooting this? I'm afraid my knowledge is a bit AJAX deficient. Are there any debug or verbose options that can be set? --17 March 2007
the best checklist is probably this talk page. Look at the problems other users where having, and how they resolved them. You can set Manual:$wgDebugLogFile, but i'm not sure if that would help you. Well it might give a clue why Special:CategoryTree dosn't work. You can also increase error verbosity:
             $wgShowExceptionDetails = true;
             $wgShowSQLErrors = true;
             ini_set("display_errors", 1);
HTH -- Duesentrieb 01:01, 18 March 2007 (UTC)
Excellent, thanks for the direction. I'll report back if I find the cause/fix. --20 March 2007

Leere span Einträge

Zwei kleine Verbesserungsvorschläge für CategoryTree

1. In der README steht noch


2. was wichtiger ist, wenn nicht nur Kategorien, sondern auch Seiten im Baumansicht angezeigt werden, kommt es zu leere <span> Tags im HTML-Code. Um das umzugehen, habe ich eine kleine Änderung in CategoryTreeFunctions.php vorgenommen:

Ab Zeile 334

 $s .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeBullet' ) );
 if ( $ns == NS_CATEGORY ) {
   $s .= '[' . wfElement( 'a', $linkattr, $txt ) . '] ';
 } else {
   $s .= ' ';
 $s .= wfCloseElement( 'span' );

wenn man die span-Tags ins if verschiebt, werden die Seiten wieder W3C passend

 if ( $ns == NS_CATEGORY ) {
   $s .= wfOpenElement( 'span', array( 'class' => 'CategoryTreeBullet' ) );
   $s .= '[' . wfElement( 'a', $linkattr, $txt ) . '] ';
   $s .= wfCloseElement( 'span' );
 } else {
   $s .= ' ';

Desweiteren sollte die Versionsnummer in der README stehen, ich habe kA., ob ich die neuste hier habe ;-)

-- Miki11 14:02, 25 March 2007 (UTC)

fixed. -- Duesentrieb 13:59, 30 March 2007 (UTC)

depth problem

having loaded the current 1.9.3 of MW, and download the bleeding edge of your extension, we are having problems getting the depth to start out displaying to level 5.

I am sure I have missed something in the setup but ??

You mention in the doc that the depth is dependant on the mode i believe but nowhere do I see that defined.

thanks --Dtsig 20:10, 12 April 2007 (UTC)

As stated in the documentation, it's defined by $wgCategoryTreeMaxDepth. I have added an example to Extension:CategoryTree#Options, I hope it helps. -- Duesentrieb

Still missing the boat
Thanks for that. Here are the settings ..

$wgUseAjax = true;
require_once( 'extensions/CategoryTree/CategoryTree.php' );
$wgCategoryTreeMaxDepth = array(CT_MODE_PAGES => 5, CT_MODE_ALL => 5, CT_MODE_CATEGORIES => 5);

Tag in page

<categorytree mode="all"; depth=5; style="float:right; clear:right; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;">WIKISANMAR.CATEGORIES</categorytree>

initially i get this ..


If expand project, project-it, project-it-functional I would think i would see the '872-Hal Environments' which is a page which is linked to category project-it-functional.

no subcategories

Sorry if i am blundering this all up. I would think that 'all' would show pages and categories and that depth=5 would at least show to 5 indents. Have tried various nubmers but no matter what i change this to i don't get any changes. i just can't see where i have gone wrong --Dtsig 19:42, 18 April 2007 (UTC)

I'm not sure if this is actually your problem, but your syntax is broken:
   <categorytree mode="all"; depth=5; style="...">
is wrong. should be:
   <categorytree mode="all" depth="5" style="...">
try it... -- Duesentrieb 21:18, 18 April 2007 (UTC)

You are the man .. thanks a lot --Dtsig 17:33, 19 April 2007 (UTC)

Building a test category hierarchy

For all those people that are new to wiki category concept and CategoryTree, like me, here is a *nix command line script to build a test category hierarchy for you (tested under Bash):

# category id

echo "[[Category:Test P$ctid]]" > "Category:Test P$((ctid+1))".txt
php maintenance/importTextFile.php !$


Basically, you initial the category id variable and then, import the generated file into wiki, increase the category id variable, then loop the procedure to whatever depth you want.

--19 April 2007

Error: categoryTreeExpandNode is not defined

Everytime I click on a + I get:

Error: categoryTreeExpandNode is not defined
Source File: http://www.ibsurvival.com/wiki/index.php?title=Category:Subjects
Line: 1


Error: categoryTreeExpandNode is not defined
Source File: http://www.ibsurvival.com/wiki/index.php?title=Category:Biology
Line: 1

So on and so forth (category varies)...

Any ideas? --Deus 21:35, 20 April 2007 (UTC)

see Clicking the [+] has no effect / gives JavaScript error and the section following that. -- Duesentrieb 21:44, 20 April 2007 (UTC)
I looked at those and I'm afraid I don't really understand:
Make sure your Webserver uses the correct mime types for .js and .css files
Enter the URLs directly into the browser and see if it is serving the pages at all, and not some error page; especially
--Deus 21:48, 20 April 2007 (UTC)
Looking at the HTML from your wiki, it seems like your custom skin doesn't output the head scripts. When using a monobook/skintemplate based skin, you'd get those from $this->html('headscripts'), otherwise you'll somehow fetch them from $wgOut->getScript(). Those scripts have to go into the html head section; they are used by many extensions and some built-in functions too. -- Duesentrieb 22:56, 20 April 2007 (UTC)
Ah I know what you are saying. I'll change that ASAP and let you know how it goes. Thanks.
It works! I just added $this->html('headscripts') to the skin and it seems to work fine. Thanks a million. Appreciate your help. :) --Deus 07:03, 21 April 2007 (UTC)

One last thing, is it possible to make mode="all" by default? --Deus 21 April 2007

not without hacking the source. Have a look at efCategoryTreeParserHook if you want to do that. -- Duesentrieb 11:41, 21 April 2007 (UTC)
Where exactly should I be looking? Thanks again for your help. --Deus 08:48, 22 April 2007 (UTC)
You should look for the place where the default mode is set if no "mode" argument is provided. If you can't find that in that function, you probably shouldn't touch the source... -- Duesentrieb 11:06, 22 April 2007 (UTC)

Category Pages mode different

I have installed CategoryTree and made a few changes:

* changing default mode to ALL in efCategoryTreeParserHook 
* omiting namespace

But when I go to a Category Page, the tree's mode appears to be Categories.

Does the CategoryPageSubclass.php file not use the default mode from CategoryTree.php? 19:31, 24 April 2007 (UTC)

it uses CategoryTree::renderNode directly, which defines its own default. See the renderNode function in CategoryTreeFunctions.php. Perhaps the default mode should indeed be a configuration option... -- Duesentrieb 19:37, 24 April 2007 (UTC)

Is there a work around for this? I would really like to see the pages listed under the subcategories on a category page. -- 18:45, 30 April 2007 (UTC)

I have added options for the default mode for tags, and the mode used on category pages. Documentation has been updated. -- Duesentrieb 12:16, 1 May 2007 (UTC)

More on Error: categoryTreeExpandNode is not defined

I to am having the same problem. I have looked at the trouble shooting page reference above and I see "If you are using rewrite rules or aliasing". I have checked my .htaccess and I am not doing anything there. When i enter the URL for the javascript file directly I do get redirected to the index page though.

The header fix mentioned above does not appear to be in in SVN yet. Not sure is this will fix my problem but can you give me a hint one which file / where is would implement it - many thanks --JulianY 07:28, 28 April 2007 (UTC)

Find out why your are being redirected when accessing the script. That is your problem right there, and there's nothing MediaWiki can do about it (this is a request for a plain file - MediaWiki is not even called. Or shouldn't be); If there's nothing in the .htaccess file, check .htaccess files in "parent" directories, and also for aliases defined in httpd.conf. Also make sure apache is allowed to serve files directly from the extension directory - maybe that is the problem.
the "header fix" discussed was only for the custom skin he was using. It simply works with all the default skins. -- 09:43, 28 April 2007 (UTC)

OK will do but i have a work around using a seperate server for the moment --JulianY 13:32, 2 May 2007 (UTC)

Enhancement Suggestions

This is a realy great extension and I would like to make a couple of enhancement suggestions;

  • mode="hideEnptyCatagories" this would hide category subtrees that do not contain any pages.
  • colls="#" this would instruct the categorytree tag to lay it's contents over a number of columns
  • hidenamespace="true" so categories would be displayed at "Coaches Australia" not "Category:Coaches Australia"

Lastly a catagoryreecontents tag. When a tree node is expanded the content of the node is then displayed in this tag - if present --JulianY 13:32, 2 May 2007 (UTC)

is this possilbe? in would like to have the tree split in 3 columns (because it's big) -- 12:27, 23 October 2007 (UTC)

Possible to show all categories

I have a very small wiki, with a very flat category structure. Is it possible to modify your script so it shows all the categories (they have no common root). I could just put multiple trees, one for each category, but then I would have to update it every time there was a new category. --5 May 2007

I would like to second this request. I also have a small site with relatively few categories and. My maximum depth is 3 or 4. - Tnabtaf 00:03, 29 January 2008 (UTC)
Just make a root category, and hide it when showing the tree. -- Duesentrieb 14:59, 29 January 2008 (UTC)

Here is a quick and dirty patch to do it (just let the categorytree tag with an empty category name):

--- CategoryTree/CategoryTreeFunctions.php	2008-06-10 11:49:07.968750000 +0900
+++ CategoryTree2/CategoryTreeFunctions.php	2008-06-13 18:06:00.578125000 +0900
@@ -122,20 +122,32 @@
 		$this->mIsAjaxRequest = false;
 		$category = trim( $category );
-		if ( $category === '' ) {
-			return false;
-		}
-		if ( $wgCategoryTreeDisableCache && !$wgCategoryTreeDynamicTag ) {
-			$parser->disableCache();
+		if ( $category !== '' ) {
+			if ( $wgCategoryTreeDisableCache && !$wgCategoryTreeDynamicTag ) {
+				$parser->disableCache();
+			}
+			$title = self::makeTitle( $category );
-		$title = self::makeTitle( $category );
-		if ( $title === false || $title === NULL ) return false;
 		$html = '';
 		$html .= Xml::openElement( 'div', array( 'class' => 'CategoryTreeTag', 'style' => $style ) );
-		if ( !$title->getArticleID() ) {
+		if ( $category === '' || $title === false || $title === NULL ) {
+			$dbr = wfGetDB( DB_SLAVE );
+			$sql  = 'SELECT page_title AS title '; /* categories not belonging to any category */
+			$sql .= 'FROM '.$dbr->tableName('page').' ';
+			$sql .= 'LEFT JOIN '.$dbr->tableName('categorylinks').' ON page_id=cl_from ';
+			$sql .= 'WHERE cl_from IS NULL AND page_namespace='.NS_CATEGORY.' AND page_is_redirect=0 ';
+			$sql .= 'UNION ';
+			$sql .= 'SELECT cl_to AS title '; /* categories without associated page */
+			$sql .= 'FROM '.$dbr->tableName('categorylinks').' ';
+			$sql .= 'LEFT JOIN '.$dbr->tableName('page').' ON cl_to = page_title AND page_namespace = '.NS_CATEGORY.' ';
+			$sql .= 'WHERE page_title IS NULL ';			
+			$res = $dbr->query( $sql );
+			while ($row = $dbr->fetchObject( $res ))
+				$html .= CategoryTree::renderNode( self::makeTitle($row->title), $mode, $depth>0, $wgCategoryTreeDynamicTag, $depth-1 );
+		}
+		elseif ( !$title->getArticleID() ) {
 			$html .= Xml::openElement( 'span', array( 'class' => 'CategoryTreeNotice' ) );
 			$html .= self::msg( 'not-found' , htmlspecialchars( $category ) );
 			$html .= Xml::closeElement( 'span' );

--13 June 2008

Darstellungsart / Viewing

de: Eine Differenzierte Darstellung wäre nett. Z.B. ein Parameter zu übergeben, welches die CategorieTrees nicht untereinander sondern nebeneinander darstellt.

en: Diffenret kinds of viewing-possibilitys. For example showing the Trees besides and not among each other.

--14 May 2007

You can do that using CSS by wrapping the category tree in a div that has a special CSS calss assigned. But i'm not sure how well a side-by-side display will work when expanding nodes... -- Duesentrieb 10:16, 14 May 2007 (UTC)
OK I added div-tags around the categorytree-tags with white-space: nowrap; but it doesn't work.
<div style="white-space: nowrap;"><categorytree mode="pages" hideroot="on">CATEGORY</categorytree></div>
I also added the white-space: nowrap; entrys to all classes in the CategoryTree.css and CategoryTree.rtl.css but nothing happens.
display: inline; doesn't work too!
Using the style-argument in your categorytree-tag has no effect on breaks
-- 10:00, 24 May 2007 (UTC)

Categories Intersection

Hi. There's a way to use CatScan categories intersection with CategoryTree? It can be useful to get automatic lists for Portals. I use CategoryTree on w:it:Portale:Anime e manga, but adding a new intersection function on CategoryTree should make it more powerful and flexible. (and discourage composite categories creation) It's implementable?--Dzag 07:42, 19 May 2007 (UTC)

CategoryTree and Version 1.10.

I am using a own wiki (Mediawiki); Version 1.10. I tried to install categoryTree: I copied the categoryTree-Folder into extensions and added the two lines

 $wgUseAjax = true;
 require_once( "{{path}}/CategoryTree.php" ); 

to the localsettings; it tried it also with the full path

require_once( "/var/www/w-handwerk/extensions/CategoryTree/CategoryTree.php" );

but I get always the error-message:

Parse error: syntax error, unexpected T_VARIABLE in /var/www/w-handwerk/LocalSettings.php on line 125

line 125 is the $wgUseAjax

what is wrong?

--DerBernie 19:10, 24 May 2007 (UTC)

Needs a mode restricting to the current page's namespace

the Pages mode leaves out articles in the Images namespace. There should also be a mode which limits articles to the same name namespace as article you're in, or a nominated namespace (as opposed to all namespaces except Images). --31 May 2007

I have a silly question.

I've installed a personal wiki on my system at home, version 1.9.3. I've installed CategoryTree and it works fine. I've set the variables -

$wgCategoryTreeOmitNamespace = true;
$wgCategoryTreeDynamicTag = true;
$wgCategoryTreeDefaultMode = CT_MODE_PAGES;
$wgCategoryTreeCategoryPageMode = CT_MODE_PAGES;

In the example shown in the box on the "Extension:CategoryTree" page, the "manual" category indents each child when you click on the minus sign. My system here at home does not indent the child pages that I create.

Q- Is there a variable that I need to set somewhere that will indent each child.

I suspect this is about me changing my style sheets or adding another extension to my system rather than what CategoryTree is doing.

--Allyn 17:25, 4 June 2007 (UTC)

I have encounted the same problem. The cause of the problem was that I have moved the extensions folder to a different location. I created a symbolic link from the original location to the new one, and then indentation worked. --Tillmo 13:05, 13 November 2007 (UTC)

Another question with 1.10.0

I've followed the instructions per the README file. When I try and use it with the tags, or use the Special to search for categories, it always says that the category cannot be found. I'm not getting any errors or anything. Any suggestions? --18 June 2007

It sounds like the problem I encountered with 1.10.1. CategoryTree will only locate categories when the category page has been created. When you open Special Pages:Categories are all of you category names red? If so then the category page has yet to be created. Try using one of the blue category names between the CategoryTree tags. If you do not have any blue category names then click on a red one, insert some text on the page, save it and then try CategoryTree again. --Pndfam05 19:40, 29 July 2007 (UTC)

Older Versions

Is there a version of this extension that will run on mediawiki 1.65? My ISP will NOT upgrade the PHP software so I can't upgrade :-( --Elihuwdr 27 June 2007

I have the same problem.. how do you locate older revisions? 18 November 2007
CategoryTree will not work with anything < MediaWiki 1.8, sorry. -- Duesentrieb 21:28, 18 November 2007 (UTC)
Looking at Wikipedia's Version page, it looks like they are running CategoryTree Version r34306 on MediaWiki 1.13alpha? --16 May 2008

categorytree inside of a template

I'm using wiki version 1.10 and as far as i can see i can't use your extension in templates. for example <categorytree mode="pages" hideroot="on">{{{COMPONENT}}}</categorytree>

where COMPONENT is a valid category the result is empty. if i hardcode the category between the tags it works. — Preceding unsigned comment added by (talkcontribs) 3 July 2007

I'm also having this problem - see Appropedia:Template:Topic bottom & Appropedia:Template:Category tree. Can this be overcome? --Chriswaterguy 09:15, 11 August 2007 (UTC)
I also would like to request this feature. ----Guoqian 09:37, 12 September 2007

This is a fundamental problem of all tag-type extensions, and there is no easy solution. see Bugzilla:2257 -- Duesentrieb 09:26, 13 September 2007 (UTC)

UPDATE: I just committed an update that allows you to use parser function syntax to put a category tree on a page - see The {{#categorytree}} parser function. Parser functions allow the use of variables, templates and template parameters. Try it. -- Duesentrieb 11:25, 13 September 2007 (UTC)

I updated the latest version, but {{#categorytree|catname}} did not work. Wiki shows {{#categorytree|catname}} itself. if I use {{#categorytree:|catname}}, Wiki shows nothing. I am using Mediawiki 1.11.0rc1, php5.1.1, mySQL 4.1.16. I have ParserFunctions extension installed. Am I missing something? ----Guoqian 12:44pm, 13 September 2007
OK. As you re-indicated in categorytree homepage, the syntax should be {{#categorytree:catname}}. It works now. Thank you very much.----Guoqian 8:05pm, 13 September 2007

Articles in more than one Category

Could you include a function, that makes filtering possible?

For example:

Article A is in Category 1
Article B is in Category 2
Article C is in Category 1 and Category 2

now I type the following code into the wiki

<categorytree mode="pages" hideroot="on">Category 1</categorytree>

the result is Article A and Article C, because they are both in Category 1

I Would prefer the following function:

<categorytree mode="pages" hideroot="on">Category 1|Category 2</categorytree>

the result is Article C because Article A would be filtered out. --18 July 2007

I don't think I'll open that can of worms. From writing meta:User:Duesentrieb/CatScan, I know that there are lots of filters that would be nice to have, and that it's quite hard to write efficient database queries for them - especially since people want to combine them.
As to your example: the syntax seems odd. To me, "|" would indicate the union, not the intersection, of the two categories. "&" could be used for intersection, but that's a valid title character, wich makes it tricky.
Maybe I'll add a way to hook into CategoryTree, to allow people to write their own filters, with a minimum of PHP codeing. But even that could proove tricky... -- Duesentrieb 13:46, 25 August 2007 (UTC)
+1. This would be very handy. Sometimes you want to display the articles that are both of one type and also of another. That avoids categories for intersections of categories, which is alot of manual and/or bot work. -- 11:42, 4 September 2008 (UTC)

Subcategory/article count

Is it possible to get a subcategory/article count (depending on the mode)? Otherwise I'm stuck with trying to do it with Dynamic Page List... -Eep² 03:33, 28 July 2007 (UTC)

Couting the elements in a category is as expensive as listing them. When showing 100 categories, it would amount to 100 additional database queries (using subqueries doesn't make it much better). This type of overhead is not acceptable. -Duesentrieb
To you, perhaps, but on a smaller wiki it's negligible. Leave it up the wiki owner to decide. -Eep
Hello? I've done it with DPL but it doesn't have the javascript branching that CategoryTree does... More suggestions for options:
  • Use images for the "[+]"/"[-]" text controls (easier to click since the brackets don't work)
Images don't scale and should be avoided as UI elements. Making the brackats clickable would be possible, but making them look link-ish would be ugly, IMHO. -Duesentrieb
Leave that up to the wiki owner as to which image should be used and how the text link should look like (like use "[$1]" in a system message and allow the $1 to be configurable too, as text or an image), but simple adding an image scale proportion adjustment parameter would be sufficient if it concerns you that much. However, you don't see such issues arise in favicons (16x16) and even default Windows desktop icon sizes (which range from 16x16 to 48x48 but 32x32 is the most common). -Eep
  • Display bullets for pages
Maybe. Yea, why not. When I have time. -Duesentrieb
  • Remember opened/closed branches (via cookie?)
this would case some massive overhead when flipping through your browser history. It would also be a mess to code, basically spamming you with dozents of cookies, or cluttering the session data on the server. I don't think it's wort it. -Duesentrieb
Again, leave that up to the wiki owner to decide. Why limit functionality based on what you think will cause "spamming" and server session data cluttering? -Eep
-Eep² 05:13, 1 August 2007 (UTC)
I second these - I think these are great suggestions (though of course I'm not a coder, so that's just my opinion). Also, I hope that in time, cats without subcats will automatically display a "[-]" instead of a "[+]" even before being clicked. --Chriswaterguy 09:15, 11 August 2007 (UTC)
$wgCategoryTreeOmitNamespace "doesn't show the namespace name for pages and categories. Default is false, namespaces are shown unless showing categories only." But I would like an option to show all namespaces except "category:" for all modes. Specifically, I want "template:" visible with CT_MODE_ALL and CT_MODE_PAGES and I would like to force more than one level of branching to automatically open. I can't get this to work at all even with this: $wgCategoryTreeMaxDepth = array(CT_MODE_PAGES => 3, CT_MODE_ALL => 3, CT_MODE_CATEGORIES => 3);. —Eep² 07:53, 25 August 2007 (UTC)
This would be inconsistent, since Pages would look the same as Categories (ok, except for the [+] up front). I don't like inconsistencies like that, and too many modes make the code overly complex (see en:Feeping_creaturism); -Duesentrieb
It's not, really. This is for when pages are displayed under categories, because there is only italics to represent pages/articles, categories are distinguished. However, if there are templates and other namespaces, same-named pages in different namespaces look like duplicates. I'd rather have the namespace in front for pages/articles under subcategories in these instances. -Eep
Opening more level initially: I don't really like this feature, it was added by someone else. However, it seems to work ok when I tested it, and your configuration looks fine (assuming you are setting the depth attribute in the <categorytree> tag). -Duesentrieb
No, I'm not using a tag but instead the default category page. I want at least the first level open for each subcategory on category pages by default without having to use a tag. -Eep
Regards -- Duesentrieb 14:03, 25 August 2007 (UTC)
Eep² 22:34, 26 August 2007 (UTC)

how to set colors for category entries

Is there any way to set different colors for category entries based on some simple conditions? Thanks. -Guoqian 2 August 2007

Problems on MW 1.10.1

When clicking the [+] next to a category tree, I get:

       400 Bad Request: 
       Warning: in_array() [function.in-array]: Wrong datatype for
       second argument
       in /var/www/mw_codebase/1.10.x/w/includes/AjaxDispatcher.php on
       line 61
       Bad Request
       unknown function efCategoryTreeAjaxWrapper

I'm using

  • CategoryTree, downloaded from svn trunk today 9:th of Aug 2007
  • - (tried as well with the version from 2006 on http://tools.wikimedia.de/~daniel/downloads/ with the same result)
  • MediaWiki 1.10.1
  • Ubuntu server 6.06
  • Apache 2.0.55
  • PHP 5.1.2

It seems like Wikia had the same problem, see: http://www.wikia.com/wiki/Forum:Category_tree

Anyone details about how this was solved, anybody? Best Regards, --SHL 13 August 2007

Changes for $wgCategoryTreeCategoryPageMode show no effect

I'm Using MW 1.10.0. I tried to change the category page mode to CT_MODE_PAGES but it's showing no effect. I read the Troubleshooting, should work fine. What did I forget?

-- 15:39, 15 August 2007 (UTC)

Same Problem. I Use
$wgCategoryTreeDefaultOptions=all; because i want that all pages in the category X ist listen below that. --2 July 2008
try again, and read closely: $wgCategoryTreeCategoryPageMode = 'all';
what version are you using, btw? -- Duesentrieb 14:31, 2 July 2008 (UTC)
can't remember. I've installed the latest version now (r38543) but I still do have the same old problem. should get that extension working, soon... :/ .. MW Version is 1.12.0 -- 10:56, 4 August 2008 (UTC)
The latest version does not work with 1.12. Pick 1.12 on Special:ExtensionDistributor/CategoryTree or wait for 1.13 to be released (should happen any minute now). -- Duesentrieb 14:18, 4 August 2008 (UTC)
awesome, it's working. after all.
thanks a lot daniel! -- 10:07, 28 August 2008 (UTC)

CategoryTree in SideBar Problem

Hi guys hope you can help. Ive got the CategoryTree working in the SideBar but there is a problem. It works fine when expanding out the tree on the Main Page. I can click on a child on the Main page and it goes to the right location. However, when Im at the new location other than the Main Page, I get a similar problem to what has already been discussed under "Clicking the [+] has no effect / gives JavaScript error".

The thing is:
1) On the new page, I can click on the root of the category tree, and it takes me to the right location.
2) On the new page, I can click on the root and goes to that root fine, but I cannot expand that roots children out. I CAN expand the CategoryTree out successfully on the Main Page only, but no other page.

The error code Im getting on pages other than the Main Page when using the CategoryTree from the sidebar is:
Line 671
Error:Object Expected
URL: <the url of the new page Im currently on>
I have checked all is correct with the notes on "Clicking the [+] has no effect / gives JavaScript error".


On the Main Page:

I can expand the category tree successfully, and click on children successfully.

On Pages other than the Main:

# I can click on the root of each category and go to that page:
[+]Category (If I click this, it goes to this page)
[+]Category (If I click this, it goes to this page)
[+]Category (If I click this, it goes to this page)
eg. [+]VBScript  (If I click on VBSScript, it goes to http://localhost/mediawiki/index.php/Category:VBScript
# If I try and click on the [+] sign next to the Category Name, eg. the [+] next to VBScript, I get the error message.
When I hover over the [+] next to VBScript, the path is looking at http://localhost/mediawiki/index.php/Category:VBScript#

Questions. This error Im getting. What file is the error coming from, and how to correct? Thank you. --2 September 2007

Solution Found

Hi guys I posted a question on discussion and thought I share Duesentrieb's solution which WORKS!! yay! Problem:
Ive got the CategoryTree working in the SideBar but there is a problem. It works fine when expanding out the tree on the Main Page. I can click on a child on the Main page and it goes to the right location. However, when Im at the new location other than the Main Page, I get a similar problem to what has already been discussed under "Clicking the [+] has no effect / gives JavaScript error".
Open CategoryTree.php, find the function efCategoryTreeParserOutput, Change it to read:

function efCategoryTreeParserOutput( &$outputPage, &$parserOutput )  {
                CategoryTree::setHeaders( $outputPage );

Thank you Duesentrieb --3 September 2007

A Small Modification

Just add the

return true;

to the above codes to avoid internal wrong massages if you get them:

function efCategoryTreeParserOutput( &$outputPage, &$parserOutput )  {
                CategoryTree::setHeaders( $outputPage );
                return true;

--31 July 2008

Adding a Category Tree [+] Tab next to Edit, History, Protect, Delete

Hi guys,
Just wondering how you would go about adding: 1) An extra tab next to Edit, History, Protect, Delete, for every page. 2) A Category Tree [+] tab next to Edit, History, Protect, Delete, for every page.
Thank you. --7 September 2007

What exactly would that tag do? Take you to Special:CategoryTree? It can't expand in-place, that would put the tree inside the tab... or would you want something like a "popup"?
Also, what category should that tab refer to? Or do you only want it on category pages?
Furthermore, "+" is a bad choice: On talk pages, there already is a tab labeled "+", which creates a new section.
Can you clarify? -- Duesentrieb 09:31, 13 September 2007 (UTC)

Category not found with mediawiki 1.11.0

On a brand new installation of mediawiki 1.11.0 I've created two categories using Extension:TagAsCategory and they both appear in Special:Categories, however neither can be found on Special:CategoryTree. I have added pages to both categories yet Special:CategoryTree reports "Category ... not found".
Thanks, Simon. 18 September 2007

Please give a link to a page that shows this problem, or at least explain exactly what the categories are called, and what syntax and parameters you used with CategoryTree -- Duesentrieb 08:38, 18 September 2007 (UTC)

Ok, sorry for not explaining in more detail. Unfortunately I cannot provide an external link to the wiki. I have two categories; "Testcat" and "Othercat". Testcat has two pages, "Testpage" and "Testpage2". Othercat has "Testpage3" and "Testpage4". On the Special:Categories page both Categories are listed successfully and they both have 2 members each. However when I search for Testcat or Othercat on the Special:CategoryTree page it returns "Category Testcat not found". Also, when I insert <categorytree>Testcat</categorytree> into the page markup the page displays "Category Testcat not found". I have Javascript enabled and I created the two categories using Extension:TagAsCategory. I downloaded CategoryTree from svn on Tuesday 18th Sept. Thanks in advance. --24 September 2007

Do the category pages exist? i.e. are links to the category blue? if they are red, the category has "content", but no "page", and categorytree will list them as non-existant.-- Duesentrieb 13:48, 24 September 2007 (UTC)
Yep, thats the problem. Many thanks! --28 September 2007

Clicking on [+] results in loading but nothing loads

I have a problem, I installed categorytree on my wiki (http://sustainablex.com/en/index.php?title=Portal:Wind) but when I open the [+] the tree it stops at loading. I also have the same problem as the previous post. --Sustainablex 21 September 2007

Extension:CategoryTree#Troubleshooting -- 14:42, 21 September 2007 (UTC)
  • The server serves the js files to the browser
  • Hack to load files on each page made
  • Latest svn installed
I am still having no joy with this and I really need this extension to work, thanks for any suggestions. Sustainablex 10:35, 22 September 2007 (GMT)
check the error console for any js errors you might be getting. -- Duesentrieb 13:46, 24 September 2007 (UTC)
I encounter the same problem - although I have checked all the things in Extension:CategoryTree#Troubleshooting.
As reported under "Problem with Firefox" above, Firfox error console reports: "Fehler: uncaught exception: Die Erlaubnis für den Aufruf der Methode XMLHttpRequest.open wurde verweigert" meaning "Error: uncaught exception: The permission to call the method XMLHttpRequest.open was not granted".
However, this is not a firefox problem! Namely, with my Firefox I can use the category tree on Extension:CategoryTree without any problems. Hence, this wiki must be configured somehow in a way different from my wiki. Any hints? --Tillmo 10:49, 4 November 2007 (UTC)
I solved the problem through my ISP. I checked an option in my ISPs control panel to enable it to run scripts, this took a day or so for them to move it to a server that ran scripts. Also a minor frustration I had was getting the tree to work on a wiki page, it turns out that it will not load unless the category has a parent or something written in it. -- Sustainablex 09:34, 07 Novemeber 2007 (BST)
By chance, I solved the problem in the following way: in the file includes/DefaultSettings.php change the following (MediaWiki version 1.11.0):
<     && (    ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 )
>     && (    ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 8080  )
You can also save these lines into a file named patchfile and then execute
patch DefaultSettings.php patchfile
--Tillmo 12:36, 13 November 2007 (UTC)

Reverse Proxy Engineered Wiki

Same problem occures while trying to reverse proxy a wiki. This technique is commonly used by corporate intranet sites and wiki's, e.g. External address: https://company.com/wiki, Internal address: http://co.local/wiki.

Solution: (works on intranet as well as 'outside'):
Change the wiki/skins/common/ajax.js as followed:

Index: intranet/wiki/skins/common/ajax.js
--- intranet/wiki/skins/common/ajax.js (revision 1874)
+++ intranet/wiki/skins/common/ajax.js (revision 2025)
@@ -81,7 +81,7 @@
 	var uri;
 	var post_data;
-	uri = wgServer +
-		((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript) +
+	uri = ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript) +

Reason: wgServer is your local server Address (i.e. 10.0.0.x).

Now your employee loggs on from an external source and tries to access https://company.com/wiki, but gets the imfamous "Error: uncaught exception: The permission to call the method XMLHttpRequest.open was not granted" error message (in FF at least he does, otherwise he gets an Access Denied Error on

line ~109, char 3).

Keep in mind that wgServer points to an internal IP-address, and is invalid for an external user.

Hope this can be fixed in future releases of MediaWiki, absolute URLs must be avoided, due to portability, migration and rare cases of reverse proxy engineered intranet-sites.

--Kaspera 11:39, 3 December 2007 (UTC)

Omit Namespace

Is there a way to omit the namespace without using $wgCategoryTreeOmitNamespace = true? I'm on Wikipedia and wish to use <category tree> with this enabled (or rather disabled) for all viewers without having to instal the CategoryTree extension. Is there a way to do this similar to how mode is chosen (<category tree mode="all" '''omit namespace="on"'''>)? --22 September 2007

I'm very reluctant to add more options, for technical reasons: adding an option means adding parameters to multiple php functions, and mutliple places in the JavaScript code, and also considering all options when creating cache keys - all of which needs to be kept consistent. this makes the code more prone to oversights and errors, and it also makes caching less effective.
This is a general problem with ajax-based extensions. If I come up with a nice and clean mechanism to handle options for ajax calls, I'll be happy to use it for the category tree too. -- Duesentrieb 08:52, 22 September 2007 (UTC)
Sounds like the code isn't optimized very well then... You may want to consider a rewrite so adding things is easier. I'd like to be able to have the non-category namespaces show, for example, but as CategoryTree currently is coded, it's all namespaces or nothing. :/ —Eek 21:07, 22 September 2007 (UTC)
optimization is about performance, not about flexibility or modularity of the code. But yes, it sucks that it's hard to add options. Feel free to rewrite it. I have it on my todo list, somewhere around position 42311. -- Duesentrieb 21:50, 26 September 2007 (UTC)


The depth option will not work for me on Wikipedia. When I put <categorytree mode="all" depth="4" hideroot="on">, the mode and the hideroot worked, but the depth stayed at 1 (only the first layer shows up). Am I doing something wrong? --22 September 2007

Depth is limited to 1 on Wikipedia. Loading multiple levels causes a lot of database requests, especially if there are a lot of categories (like on wikipedia). Consider what happens if there are 10 subcategories per category: one wuery for the first level, ten for the second, 100 for the third, 1000 for the fourth level. That's 1111 db queries for every page view! And wikipedia has a lot of page views. That's why it's not enabled. -- Duesentrieb 08:38, 22 September 2007 (UTC)

How to use it in the Sidebar?


I'm trying in vain to use it in my MW sidebar... I modified the CategoryTree.php file (commenting the test as described on this extension page) but it seems there's no way for this to work.

What's the correct lines to add to MediaWiki:Sidebar in order to show the category tree in the sidebar?


cfab 22 October 2007

To be honest, I don't know, I never tried :) Others seem to have done it. -- Duesentrieb 13:54, 30 October 2007 (UTC)
Today I added a working solution. --WIKImaniac 18:33, 7 January 2008 (UTC)

How can I add an image instead of +/- signs

Thanks for this nice extension. How can I replace the +/- signs with some images. like folder closed/open? where to change?

Jack 30 October 2007

Currently, there'S no clean way to do that. It's a bit tricky because it would have to be configurable in PHP and in JavaScript code. You'll have to hack it in directly, sorry.
I also feel that images are a bad idea for this, since they don't scale with the text. -- Duesentrieb 13:52, 30 October 2007 (UTC)

Clicking on [+] results in message Problem loading data. Please wait a moment and try again.

I have this problem - installed CategoryTree in the latest version (http://www.ppoe.at/leiter/wiwo/wiki/index.php/Kategorie:Hauptkategorie). I am running MediaWiki: 1.8.2, PHP: 5.1.1 (apache2handler), MySQL: 4.1.16-nt. Have anyone an idea? I have tested it with Internet Explorer 7, 6 and 5 and Mozilla Firefox - same results with every browser...

Can anybody help? Wäre echt super... Schon jetzt Danke dafür!

lg Tobias 12 November 2007

Problem gelöst mit Update auf neueste Mediawiki-Version - glg Tobias 21 November 2007

Something related to category tree : a category tree in each article

Today we have something like this

Categories: 1540 births | 1603 deaths | French mathematicians | Pre-19th century cryptographers | 16th century mathematicians | 17th century mathematicians | Algebraists | French cryptographers

May be we could propose something more complexe for category debuggers

Category - 1540 biths + 1540 
                      - 1540s births + 1540s 
                                     + 16th century births
         - 1603 deaths + 1603 
                       + 1600s deaths
       | - French mathematicians + Mathematicians by nationality  (these are the parent categories)
       |                         + French scientists 
       |                         + French people by occupation 
       + Basque mathematicians  (These are the sub categories)
         + Pre-19th century cryptographers
         + 16th century mathematicians 
         + 17th century mathematicians 
         + Algebraists 
         + French cryptographers

Any thoughts ! May be this tool already exists ?

Xmlizer 13:20, 17 November 2007 (UTC)

interwiki Tree's

Is there any possibility to show a category tree from commons in any other wiki projekt. Especially I want to show a commons category tree in the german language wikisource. Thanks for your help. --Joergens.mi 18:44, 24 November 2007 (UTC)

This is currenlty not supported. Not sure if it's a good idea to add it - though it would probably not so very hard. maybe, someday. -- Duesentrieb 15:31, 6 January 2008 (UTC)


I support the Category Tree --xgmx (T | C | W | P | T) 23 December 2007

Return to "CategoryTree/Archive 01" page.