Extension:CategoryTree
|
CategoryTree Release status: stable |
||
|---|---|---|
| Implementation | Tag, Parser function, Special page | |
| Description | Provides a dynamic view of the wiki's category structure as a tree. | |
| Author(s) | Daniel Kinzler (Duesentriebtalk) | |
| Latest version | continuous updates | |
| MediaWiki | 1.23+ | |
| Database changes | No | |
| License | GNU General Public License 2.0 or later | |
| Download |
README |
|
|
||
|
||
|
Translate the CategoryTree extension if it is available at translatewiki.net |
||
| Check usage and version matrix; code metrics | ||
| Open tasks · Report a bug |
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, but was later integrated into the MediaWiki software with the help of Tim Starling.
Contents
Usage[edit | edit source]
CategoryTree can be used in three ways:
- directly on the category pages,
- as a "custom tag" (or "parser function") 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.
The <categorytree> tag[edit | edit source]
Example. The result can be seen in the box below and on the right:
<categorytree mode=pages>Manual</categorytree>
The custom tag is called <categorytree>. For example, if you put <categorytree>Foo</categorytree> 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:
- mode
- determines which pages are shown in the tree. This may be overridden by the use of the namespaces option. Possible values:
- categories
- show subcategories only (configuration constant CT_MODE_CATEGORIES)
- pages
- show subcategories and pages, except images (configuration constant CT_MODE_PAGES), limited to 200 pages
- all
- show all pages, subcategories, images, etc (configuration constant CT_MODE_ALL)
- parents
- list parent categories instead of subcategories (configuration constant CT_MODE_PARENTS). This puts CategoryTree into "inverse" operation (supported since rev:36892, July 2008).
- depth
- determines how many levels of the tree are shown initially. Default is 1. 0 means only the root node. The maximum value depends on the mode specified, and on the $wgCategoryTreeMaxDepth option. (introduced between rev:r20410 and rev:20840, Mar 30 2007; fully functional even with $wgCategoryTreeDynamicTag since rev:36864, July 2008)
onlyrootset this to "on" to only show the "root" node of the tree initially. Equivalent to depth="0". (introduced in rev:20385, March 13 2007)Deprecated as of rev:36864, July 2008: use depth="0" instead.- hideroot
- set this to "on" to hide the "root" node of the tree, i.e. hideroot=on. For example, it will not display the category name Foo.
- hideprefix
- determines when the namespace prefix should be hidden from entries in the tree (since rev:36864, July 2008). Possible values are:
- always
- always hide the prefix. Should be used only if all pages come from the same namespace (configuration constant CT_MODE_CT_HIDEPREFIX_ALWAYS).
- never
- never hide the namespace prefix, not even for categories (configuration constant CT_MODE_CT_HIDEPREFIX_NEVER).
- auto
- hide the namespace of categories, if only categories are shown, as with mode="categories" (configuration constant CT_MODE_CT_HIDEPREFIX_AUTO); This is equivalent to the old default behavior (before Jun 2008).
- categories
- always hide the namespace of categories, but show all other prefixes (configuration constant CT_MODE_CT_HIDEPREFIX_CATEGORIES). This is the new default behavior (since rev:36864, July 2008).
- showcount
- set this to "on" to show the number of entries in subcategories, i.e. showcount="on" (since rev:36864, July 2008). This is disabled per default for category trees inlined on pages, but enabled per default in category listings and on Special:CategoryTree.
- namespaces
- a list of namespaces from which pages should be shown in the tree (since rev:36864, July 2008). The entries in the list must be namespace names, separated by spaces. The main namespaces can be represented by "-" or "0". This overrides the mode option.
- class, style, id, etc
- The <categorytree> tag supports all standard HTML attributes for block elements (since rev:36864, July 2008. Before that, only style was supported).
The {{#categorytree}} parser function[edit | edit source]
Since rev:25825 (2007-9-13), you can also use parser function syntax to place a category tree on a page. This works just like the <categorytree> tag, using a different syntax, e.g. {{#categorytree:Foo}}; options can be specified using the syntax for named template parameters, e.g. {{#categorytree:Foo|hideroot|mode=pages}}.
Using the parser function syntax has the advantage that it allows you to use magic words, templates and template parameters when specifying the category to show. Some examples:
- Using a magic variable to show "this pages" category tree (may be useful on category description pages): {{#categorytree:{{PAGENAME}}}}.
- Using a template to specify the category: {{#categorytree:{{root category}}}} - the name of the root category would be defined by the contents of Template:Root_category.
- Using a template parameter to specify the category, when using CategoryTree inside a template: {{#categorytree:{{{1}}}}} in Template:Baz can be called using {{Baz|Foo}}
The Special:CategoryTree page[edit | edit source]
The special page is called Special:CategoryTree; there you can enter the name of a category and then browse its content.
Installation[edit | edit source]
- Download and place the file(s) in a directory called
CategoryTreein yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/CategoryTree/CategoryTree.php";
$wgUseAjax = true;
Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Note: $wgUseAjax = true will enable the AJAX framework in MediaWiki, which is required by the CategoryTree extension. AJAX is a term relating to the use of JavaScript to load parts of a page on demand. It is supported by all recent graphic web browsers.
Configuration[edit | edit source]
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 <categorytree> tag. Default is true.
- $wgCategoryTreeDynamicTag
- loads the first level of the tree in a <categorytree> dynamically. This way, the cache does not need to be disabled. Default is false.
- $wgCategoryTreeDisableCache
- disables the parser cache for pages with a
- GPL licensed extensions
- Stable extensions
- Tag extensions
- Parser function extensions
- Special page extensions
- Extensions in Wikimedia version control
- ArticleFromTitle extensions
- Debug extensions
- MakeGlobalVariablesScript extensions
- OutputPageParserOutput extensions
- OutputPageMakeCategoryLinks extensions
- ParserFirstCallInit extensions
- SkinTemplateOutputPageBeforeExec extensions
- All extensions

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
