Memory Alpha


36,856pages on
this wiki
Revision as of 18:11, June 1, 2012 by Renegade54 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Help icon  Contents → 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 User: Duesentrieb/CategoryTree at Meta-Wiki). It was later integrated into the MediaWiki software with the help of Tim Starling.

Usage Edit

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 [+] or [×] "expand" widgets to the subcategories listed on category pages, where [+] indicates the presence of further subcategories and [×] indicates the absence of them. 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 such.

The <categorytree> tag Edit


<categorytree mode=pages style="float:right; 
border:1px solid gray; 
background-color:black;">Memory Alpha images</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 an HTML-like syntax:

can be "categories", "pages" or "all" - see the Modes section below for the meaning of each. The default for this attribute is controlled by $wgCategoryTreeDefaultMode, and is initially set to CT_MODE_CATEGORIES, the equivalent of setting the mode attribute to "categories".
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.
set this to "on" to only show the "root" node of the tree initially. Equivalent to depth="0".
set this to "on" to hide the "root" node of the tree, i.e. the mention of category Foo from the example.
can be used to specify any CSS styles you would like for the tree.

The {{#categorytree}} parser function Edit

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

The special page is called Special: CategoryTree; there you can enter the name of a category and then browse its content. The CategoryTree extension also adds a tab for this special page to every category page.

Modes Edit

The category tree can be shown in different modes, determining what types of "leaves" the "tree" has:

  • categories (constant CT_MODE_CATEGORIES): show subcategories only
  • pages (constant CT_MODE_PAGES): show subcategories and pages, except images
  • all (constant CT_MODE_ALL): show all pages, subcategories, images, etc

More informationEdit

For more information on the CategoryTree extension, see Extension: CategoryTree at MediaWiki.

Around Wikia's network

Random Wiki