User:*Surak*/Extension:NiceCategoryList

What can this extension do?
This extension displays a category listing, including sub-categories, in a number of useful formats. This is intended to allow easier navigation of a wiki's category tree. It implements a new tag,, which generates a list of all pages and sub-categories in a given category. The list can display multiple levels of sub-categories, and has several options for the display style.

This extension was originally created by Kichik as Extension:NiceCategoryList, and has been enhanced by JohanTheGhost and *Surak*.

Parameters
The  tag displays a category list:

Category:Some Category

The tag takes the following parameters, all of which are optional:
 * maxdepth= : maximum category depth to display; default 32
 * headings= : 'head' to display category headings as Wiki headings (default); 'bullet' to display category headings as bullet lists
 * showfirst= : '0' to skip top heading (default), else display it
 * headstart= : with 'headings=head', headstart is the heading level to list top-level categories with; default 2
 * style= : 'bullet' to show category contents as bullet lists (default); 'compact' for a more compact listing
 * showcats= : not '0' to display sub-category links in "bottom" (i.e. maxdepth) categories; default 0
 * showarts= : not '0' to display articles in categories; default 1
 * sort= : not '0' to sort the list alphabetically; else sort the list according to the index key; default 0
 * number= : not '0' to display only up to of articles, else display all articles; default 0
 * random= : with number not '0': display random choice of articles if random not '0', else display the first of articles; default 0

CSS Styles
The original wiki syntax created with version 2.2 was basically left, but all direct formatting was taken out. Instead the discrete elements are enclosed in DIV and SPAN tags with class names. The benefit is that you can apply styles to the items, either in Common.css, in the current skin's CSS or in your user CSS. The whole category tree is now encapsulated into a DIV container with a classname of ncl-nicecategorylist.

Each level of the category tree is encapsulated in a div container with a classname of ncl-block-{headings}-{x}. {headings} means one of the headings options, either bullet or head. {x} means a numeric value that starts at zero and is increased on each subordinate level of the category list, until maxdepth</tt> is reached.

Inside of this top DIV container, two subordinate blocks exist for the heading and the content:


 * The heading is covered by a block with a classname of ncl-heading-{x}</tt>. {x} means a numeric value that starts at zero and is increased on each subordinate level of the category list, until maxdepth</tt> is reached.  If the option showfirst=0</tt>, then the first header is not displayed.  This is the default setting, since previous versions of the extension did not display it.  The default can be overwritten by using $egNiceCategoryListShowFirst = 1;</tt> in LocalSettings.php.
 * If the option heading=bullet</tt>, the block is a DIV block displaying the category as link to the category page as bullet list item.
 * If the option heading=head</tt>, the block is a usual headings block, starting at <h{n}>. {n} means a numeric value that starts at {headstart} and is increased on each subordinate level of the category list.  The default setting is headstart=2</tt>.  It can be set back to the default of previous versions by using $egNiceCategoryListHeadStart = 1;</tt> in LocalSettings.php.  If you want to activate the first heading for a certain category list, you can use the option showfirst=1</tt> (or inactivate it with showfirst=0</tt> otherwise).


 * The content is covered by a block with a classname of ncl-content-{style}-{x}</tt>. {style} means one of the style</tt> options, either bullet</tt> or compact</tt>.  {x} means a numeric value that starts at zero and is increased on each subordinate level of the category list, until maxdepth</tt> is reached.  It contains SPAN containers with the subcategories (if showcats=1</tt>) and articles (if <tt style="color:blue;">showarts=1</tt>) of the regarding category.
 * Each subcategory is enclosed in a SPAN container with a classname of <tt style="color:blue;">ncl-subcategory</tt>.
 * Each article is enclosed in a SPAN container with a classname of <tt style="color:blue;">ncl-article</tt>.

Additionally to the above mentioned classes, some generic classes are defined to apply styles on groups of items:
 * <tt style="color:blue;">ncl-block</tt> to apply styles to all items with classnames of <tt style="color:blue;">ncl-block-bullet-{x}</tt> and <tt style="color:blue;">ncl-block-head-{x}</tt>.
 * <tt style="color:blue;">ncl-block-bullet</tt> to apply styles to all items with classnames of <tt style="color:blue;">ncl-block-bullet-{x}</tt>.
 * <tt style="color:blue;">ncl-block-head</tt> to apply styles to all items with classnames of <tt style="color:blue;">ncl-block-head-{x}</tt>.
 * <tt style="color:blue;">ncl-heading</tt> to apply styles to all items with classnames of <tt style="color:blue;">ncl-heading-{x}</tt>.
 * <tt style="color:blue;">ncl-content-compact</tt> to apply styles to all items with classnames of <tt style="color:blue;">ncl-content-bullet-{x}</tt> and <tt style="color:blue;">ncl-content-compact-{x}</tt>.
 * <tt style="color:blue;">ncl-content-bullet</tt> to apply styles to all items with classnames of <tt style="color:blue;">ncl-content-bullet-{x}</tt>.
 * <tt style="color:blue;">ncl-content-compact</tt> to apply styles to all items with classnames of <tt style="color:blue;">ncl-content-compact-{x}</tt>.

<br style="clear:both;" />

Examples
Caveat: When used in a template, the category list will not refresh immediately when reloaded; edit and save the article to see updates.

Installation
Save all files of the latest version from above into the directory, and add the following near the end of  :

If you need to install the extension into a different extensions subdirectory, use:

Configuration
If you want to inactivate the cache for pages using the extension, use:

If you want to default the <tt>headstart</tt> option to something different than '2', use:

If you want to default the display of the first heading, use: