Difference between revisions of "Extension:CategoryTree"
Line 44: | Line 44: | ||
* Using a template to specify the category: <tt><nowiki>{{#categorytree:{{root category}}}}</nowiki></tt> - the name of the root category would be defined by the contents of Template:Root_category. | * Using a template to specify the category: <tt><nowiki>{{#categorytree:{{root category}}}}</nowiki></tt> - 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: <tt><nowiki>{{#categorytree:{{{1}}}}}</nowiki></tt> in Template:Baz can be called using <nowiki>{{Baz|Foo}}</nowiki> | * Using a template parameter to specify the category, when using CategoryTree inside a template: <tt><nowiki>{{#categorytree:{{{1}}}}}</nowiki></tt> in Template:Baz can be called using <nowiki>{{Baz|Foo}}</nowiki> | ||
+ | |||
[[Category:Help]] | [[Category:Help]] |
Revision as of 09:18, 3 April 2010
The CategoryTree extension provides a dynamic view of the wiki's category structure as a tree.
CategoryTree mediawiki page can be found here.
Usage
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,
The CategoryTree extension adds [+] "expand" widgets to the subcategories listed on category pages. If Javascript is disabled, those widgets takes you to the category page (in earlier versions, it did nothing in that case).
The <categorytree> tag
Example:
<categorytree mode=pages>Parasites</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
- pages
- show subcategories and pages, except images
- all
- show all pages, subcategories, images, etc
- parents
- list parent categories instead of subcategories. This puts CategoryTree into "inverse" operation.
- 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.
- 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. Possible values are:
- always
- always hide the prefix. Should be used only if all pages come from the same namespace.
- never
- never hide the namespace prefix, not even for categories.
- auto
- hide the namespace of categories, if only categories are shown, as with mode="categories";
- categories
- always hide the namespace of categories, but show all other prefixes
- showcount
- set this to "on" to show the number of entries in subcategories, i.e. showcount="on". This is disabled per default for category trees inlined on pages, but enabled per default in category listings an on Special:CategoryTree.
- namespaces
- a list of namespaces from which pages should be shown in the tree. 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.
The {{#categorytree}} parser function
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}}