Extension:CategoryTree

The CategoryTree extension provides a dynamic view of the wiki's category structure as a tree. It uses AJAX to load parts of the tree on demand. CategoryTree was originally written by Daniel Kinzler as an external tool (see meta:User:Duesentrieb/CategoryTree). It was later integrated into MediaWiki with the help of Tim Starling.

Usage
CategoryTree can be used in three ways: directly on the category pages, as a "custom tag" to show a category structure in-line on a wiki page, and as a special page.

The CategoryTree extension adds [+] "expand" widgets to the subcategories listed on category pages. If Javascript is disabled, those widgets just do nothing.


 * Note to bot users: bots and scripts that parse the HTML of category pages can use the notree URL parameter to force the traditional output. However, HTML output is generally not stable, so it is recommended to change your script to use query.php or api.php to fetch category listings and similar.

The custom tag is called &lt;categorytree&gt;. For example, if you put &lt;categorytree&gt;Foo&lt;/categorytree&gt; on a wiki page, it will show the contents of category Foo as a dynamic tree on that page (see example to the right). The tag accepts the following attributes, using a HTML-like syntax:

The special page is called Special:CategoryTree; there you can enter the name of a category and then browse it's content. The CategoryTree extension also adds a tab for this special page to every category page.
 * hideroot: set this to "on" to hide the "root" node of the tree, i.e. the mention of category Foo from the example.
 * onlyroot: set this to "on" to only show the "root" node of the tree initially. (introduced in 20385, March 13 2007)
 * mode: can be "categories" (the default), "pages" or "all". "categories" only lists subcategories; "pages" lists all pages in the category except images; "all" shows all pages in the category.
 * style: can be used to specify any CSS styles you would like for the tree.

Installing CategoryTree
Note: The CategoryTree extension requires MediaWiki 1.8 (revision 16385 or later).

To install the required files, download the files from the SVN-source, linked in the weblink-section below. Follow the instructions in the included README.

Copy the CategoryTree directory into the extensions folder of your MediaWiki installation. Then add the following lines to your LocalSettings.php file (near the end):

$wgUseAjax = true; require_once( 'extensions/CategoryTree/CategoryTree.php' ); Note that $wgUseAjax = true; will enable the ajax framework in MediaWiki, which is required by the CategoryTree extension. AJAX is a term for using JavaScript to load parts of a page on demand. It is supported by all recent graphic web browsers.

Options
There are some options you can specify in your LocalSettings.php file:


 * $wgCategoryTreeMaxChildren: maximum number of children shown in a tree node. Default is 200
 * $wgCategoryTreeAllowTag: enable &lt;categorytree&gt; tag. Default is true.
 * $wgCategoryTreeDynamicTag: loads the first level of the tree in a &lt;categorytree&gt; dynamically. This way, the cache does not need to be disabled. Default is false
 * $wgCategoryTreeDisableCache: disabled the parser cache for pages with a &lt;categorytree&gt; tag. Default is true.
 * $wgCategoryTreeHTTPCache: enable HTTP cache for anon users. Default is false.

Options in LocalSettings.php have no effect

 * Make sure you specify the options after including the extension.

Clicking the [+] has no effect / gives JavaScript error

 * Note that using the &lt;categorytree&gt; tag in system messages (MediaWiki-Namespace) may not work as expected - this is a known caveat.
 * Make sure you have $wgUseAjax = true in your LocalSettings.php before including the extension.
 * Make sure you are using the latest version of the extension - the bleeding edge ist at
 * If you are using rewrite rules or aliasing (e.g. to have "very short URLs" - i.e. wiki pages in the document root), make sure you have an exception in place for the /extensions directory, just like you would for the /skins directory. Also see below:

Browser reports a bad MIME type for CategoryTree.js and/or CategoryTree.css

 * 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:
 * If you are using rewrite rules or aliasing (e.g. to have "very short URLs" - i.e. wiki pages in the document root), make sure you have an exception in place for the /extensions directory, just like you would for the /skins directory.

Weblinks

 * README file
 * SVN extensions module
 * URL for SVN-Download with SVN-Client
 * download area with bundled version (alternavive bundle). (NOTE: the bundled versions may not be up to date!)
 * Bug Search