Help:CategoryTree

From UBC Wiki

The CategoryTree tag can be used to generate inline lists pages within a category or subcategories.

The <categorytree> tag

The custom tag is called <categorytree>. For example, if you put <categorytree>Learning Technologies</categorytree> on a wiki page, it will show the contents of the help category as a dynamic tree on that page . The tag accepts the following attributes, using a HTML-like syntax:

Attribute Value Explanation
Mode determines which pages are shown in the tree. This may be overridden by the use of the namespaces option. It uses the following four 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
depth determines how many levels of the tree are shown initially.
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 Help.
hideprefix determines when the namespace prefix should be hidden from entries in the tree. It can be used with the following four values:
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"
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

Examples

example code explanation generated list
<categorytree>Learning Technologies</categorytree> Shows subcategories of the learning technologies category
<categorytree mode=pages>ECON</categorytree> Shows pages (and subcategories) in the ECON category
<categorytree showcount=on>Library</categorytree> Lists the number of subcategories of the category library
Library(3 categories, 27 pages, 28 files)
Non-Portal Content(5 categories)
UBC Library Internal(5 categories, 24 pages, 2 files)
Web Portal Content(7 categories, 2 pages, 5 files)

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}}[edit]The Special:CategoryTree page

Special Page

The special page is called Special:CategoryTree; there you can enter the name of a category and then browse its content.

See Also