CategoryTree Extension

From mw.mh370.wiki
Jump to navigation Jump to search


A Guide to Using MediaWiki in a Hosted Environment

An instructional website by the developer of mh370wiki.net - a MediaWiki site about Malaysia Airlines Flight MH370.


The CategoryTree extension is included with MediaWiki and installed by placing wfLoadExtension( 'CategoryTree' ); in LocalSettings.php.

The top level category in this website is Top Level. The Category Tree for this site is displayed using this statement:-

<categorytree mode="pages" depth="0">Top Level</categorytree> 

The result is a list of categories which can be expanded to list sub-categories, and finally a list of the pages in each (sub) category.


Sort Order

The sub-categories listed for the category Processes are not in alphabetic order. This is because these subcategories were added to the parent category (Processes) with a specified numeric sort order. This is shown on the category page for each sub-category Category:Install, Category:Configure, Category:Customise etc..


An Example from mh370wiki.net

Although the MediaWiki extension CategoryTree provides a way to view the category structure, it is also useful to display a list of pages which have been added to a category.

On the mh370wiki.net I have made use of this feature in the References section. How the References work behind the scenes is a complex topic, but here is an example:-

Malaysia Airlines released many Media Statements after flight MH370 went missing. Each Media Statement is reproduced in the MH370 News for 2014, but may be referred to or quoted in other articles.

Each Media Statement has been allocated a Reference ID which is also a Category name. The first Media Statement is referred to most often. The full version, including Mandarin translation, can be viewed here: Saturday, 8 March 2014

That instance has a Reference ID MAS-MS1-001-ZH which adds that Media Statement to a category with the same name MAS-MS1-001-ZH, and which links to a page of references for Malaysia Airlines' Media Statements for MH370.

Under the section for this Reference ID MAS-MS1-001-ZH there is this line:-

The code behind this line is shown below:-

<p>
   <div style="margin-left: 5.5em; float: left;">Pages or articles which refer to this resource:-</div> 
   <div class="displaytree"><categorytree mode="pages" depth="0" hideprefix="on">MAS-MS1-001-ZH</categorytree></div> 
   <div style="clear:left;"></div>
</p>

If you ignore the various styles, float and my custom class for displaying a category tree, the essential part is simply:-

<categorytree mode="pages" depth="0" hideprefix="on">MAS-MS1-001-ZH</categorytree>

The mode, depth and hideprefix are explained on the Extension:CategoryTree page.

Expanding the category tree produces a list of pages which belong to the category MAS-MS1-001-ZH.


Links

Extension:CategoryTree
https://www.mediawiki.org/wiki/Extension:CategoryTree