- This explains how to make and use a category tree. There is also a full category tree of the whole Appropedia wiki site.
Basic usage
<categorytree>Energy</categorytree> produces:
Using in templates
There is another version which uses parser functions, and can be used in templates:
{{#categorytree:CATEGORYNAME|mode=pages}}
Options
CategoryTree can be used in three ways:
- directly on the category pages (through the wiki site's settings)
- 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.
The <categorytree> tag
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 examples). The tag accepts the following attributes, using a HTML-like syntax:
- mode
- can be "categories", "pages" or "all". The default for this attribute is set to "categories". (E.g. <categorytree mode=pages>Gardening</categorytree> will show all the subcategories and pages in the Gardening category.
- 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. note: depth values greater than 1 do not (yet) work with $wgCategoryTreeDynamicTag enabled!
- onlyroot
- set this to "on" to only show the "root" node of the tree initially. Equivalent to depth="0". Deprecated USE depth="0"
- hideroot
- set this to "on" to hide the "root" node of the tree, i.e. the mention of category Foo from the example.
- style
- can be used to specify any CSS styles you would like for the tree.
Examples
Basic example
<categorytree>Water</categorytree> produces:
Example with mode and style options
<categorytree mode=pages style="float:right; clear:right; margin-left:1ex; border:1px solid gray; padding:0.7ex; background-color:white;">Soil</categorytree> produces:
Interwiki links
- mw:Extension:CategoryTree#Usage - detailed instructions on the CategoryTree page at MediaWiki.org.