Rozszerzenie:NiceCategoryList3

This page is a translated version of the page Extension:NiceCategoryList3 and the translation is 15% complete.
Podręcznik rozszerzeń MediaWiki
NiceCategoryList3
Status wydania: stabilne
px
Realizacja Znaczniki
Opis Displays a nicely-formatted category list, with versatile sub-category listing.
Autor(zy)
Ostatnia wersja 1.1.2 (2024-06-12)
MediaWiki 1.39.0+
PHP 7.3+
Licencja Licencja GNU General Public License 2.0 lub nowsza
Pobieranie github release v1.1.2
Przykład see below
  • $egNiceCategoryListDisableCache
  • $egNiceCategoryListHeadStart
  • $egNiceCategoryListInstallDir
  • $egNiceCategoryListShowFirst
‎<ncl>

The NiceCategoryList3 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, ‎<ncl>, 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 , was enhanced by JohanTheGhost and *Surak* and Crafty Coding. This was updated to work for recent version of MediaWiki by JLTRY.

Użycie

Parametry

The ‎<ncl> tag displays a category list:

<ncl [options]>Category:Some Category</ncl>

The tag takes the following parameters, all of which are optional:

Parametr Opis Domyślnie
maxdepth=<number> maximum category depth to display 32
headings=<style> head to display category headings as Wiki headings; bullet to display category headings as bullet lists head
showfirst=<bool> 0 to skip top heading, else display it 0
headstart=<number> with headings=head, headstart is the heading level to list top-level categories with 2
style=<style> bullet to show category contents as bullet lists; compact for a more compact listing bullet
showcats=<bool> not 0 to display sub-category links in "bottom" (i.e. maxdepth) categories 0
showarts=<bool> not 0 to display articles in categories 1
sort=<bool> not 0 to sort the list alphabetically; else sort the list according to the index key 0
number=<number> not 0 to display only up to <number> of articles, else display all articles 0
random=<bool> with number not 0: display random choice of articles if random not 0, else display the first number of articles 0

Style CSS

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.

<!-- Sample output for
     <ncl headings=head headstart=2 style=bullet>category</ncl>
-->
<div class="ncl-nicecategorylist>
  <div class="ncl-block ncl-block-head ncl-block-head-0">
    <h2 class="ncl-heading ncl-heading-0">
      Category Name
    </h2>
    <div class="ncl-content ncl-content-bullet ncl-content-bullet-0">
      <ul>
        <li><span class="ncl-subcategory">Subcategory Link</span></li>
        <li><span class="ncl-subcategory">Subcategory Link</span></li>
        <li></li>
        <li><span class="ncl-article">Article Link</span></li>
        <li><span class="ncl-article">Article Link</span></li>
        <li></li>
      </ul>
    </div>
  </div></div>


<!-- Sample output for
     <ncl headings=bullet style=compact>category</ncl>
-->
<div class="ncl-nicecategorylist>
  <div class="ncl-block ncl-block-bullet ncl-block-bullet-0">
    <div class="ncl-heading ncl-heading-0">
      <ul><li>Category Link</li></ul>
    </div>
    <div class="ncl-content ncl-content-compact ncl-content-compact-0">
      <p>
        <span class="ncl-subcategory">Subcategory Link</span><span class="ncl-subcategory">Subcategory Link</span> •  
        ‴  •
        <span class="ncl-article">Article Link</span><span class="ncl-article">Article Link</span> •
        ‴  •
        …
      </p>
    </div>
  </div></div>

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 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}. {x} means a numeric value that starts at zero and is increased on each subordinate level of the category list, until maxdepth is reached. If the option showfirst=0, 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; in LocalSettings.php.
    • If the option heading=bullet, the block is a ‎<div> block displaying the category as link to the category page as bullet list item.
    • If the option heading=head, 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. It can be set back to the default of previous versions by using $egNiceCategoryListHeadStart = 1; in LocalSettings.php. If you want to activate the first heading for a certain category list, you can use the option showfirst=1 (or inactivate it with showfirst=0 otherwise).
  • The content is covered by a block with a classname of ncl-content-{style}-{x}. {style} means one of the style options, either bullet or compact. {x} means a numeric value that starts at zero and is increased on each subordinate level of the category list, until maxdepth is reached. It contains ‎<span> containers with the subcategories (if showcats=1) and articles (if showarts=1) of the regarding category.
    • Each subcategory is enclosed in a ‎<span> container with a classname of ncl-subcategory.
    • Each article is enclosed in a ‎<span> container with a classname of ncl-article.

Additionally to the above mentioned classes, some generic classes are defined to apply styles on groups of items:

  • ncl-block to apply styles to all items with classnames of ncl-block-bullet-{x} and ncl-block-head-{x}.
  • ncl-block-bullet to apply styles to all items with classnames of ncl-block-bullet-{x}.
  • ncl-block-head to apply styles to all items with classnames of ncl-block-head-{x}.
  • ncl-heading to apply styles to all items with classnames of ncl-heading-{x}.
  • ncl-content-compact to apply styles to all items with classnames of ncl-content-bullet-{x} and ncl-content-compact-{x}.
  • ncl-content-bullet to apply styles to all items with classnames of ncl-content-bullet-{x}.
  • ncl-content-compact to apply styles to all items with classnames of ncl-content-compact-{x}.


Przykłady

For a full, recursive listing of all categories under a specified category, use this:

<ncl>Category:Some Category</ncl>

 

For a nice "high-level" category index, use this in a template:
<ncl style=compact maxdepth=2 headings=bullet headstart=2
     showcats=1 showarts=1>Category:{{PAGENAME}}</ncl>
and include it in major category pages to provide a nice 2-level (or however many you like) index of the category.

 

This:
<ncl style=compact headings=bullet headstart=2 showcats=1
      showarts=0>Category:Categories</ncl>
generates a full category listing, with indentation indicating category containment.

 

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

Instalacja

Konfiguracja

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

$egNiceCategoryListDisableCache = true; // disables page caching

If you want to default the headstart option to something different than 2, use:

$egNiceCategoryListHeadstart = 1; // defaults headstart to 1

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

$egNiceCategoryListShowFirst = 1; // displays first heading

Historia wersji

Version 1.1.1