Extension:NiceCategoryList3
![]() リリースの状態: 安定 |
|
---|---|
![]() |
|
実装 | タグ |
説明 | Displays a nicely-formatted category list, with versatile sub-category listing. |
作者 | |
最新バージョン | 1.1.1 (2022-12-27) |
MediaWiki | 1.39.0+ |
PHP | 7.3+ |
ライセンス | GNU 一般公衆利用許諾書 2.0 以降 |
ダウンロード | github release v1.0.0 |
例 | see below |
|
|
<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
This extension has not been tested on wikis with large (more than a hundred or so) category trees. It may be unacceptably slow on very large wikis. Use with care. |
使用法
パラメーター
The <ncl>
tag displays a category list:
<ncl [options]>Category:Some Category</ncl>
The tag takes the following parameters, all of which are optional:
パラメーター | 説明 | 既定 |
---|---|---|
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 |
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.
<!-- 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, untilmaxdepth
is reached. If the optionshowfirst=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 isheadstart=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 optionshowfirst=1
(or inactivate it withshowfirst=0
otherwise).
- If the option
- The content is covered by a block with a classname of
ncl-content-{style}-{x}
. {style} means one of thestyle
options, eitherbullet
orcompact
. {x} means a numeric value that starts at zero and is increased on each subordinate level of the category list, untilmaxdepth
is reached. It contains SPAN containers with the subcategories (ifshowcats=1
) and articles (ifshowarts=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
.
- Each subcategory is enclosed in a SPAN container with a classname of
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 ofncl-block-bullet-{x}
andncl-block-head-{x}
.ncl-block-bullet
to apply styles to all items with classnames ofncl-block-bullet-{x}
.ncl-block-head
to apply styles to all items with classnames ofncl-block-head-{x}
.ncl-heading
to apply styles to all items with classnames ofncl-heading-{x}
.ncl-content-compact
to apply styles to all items with classnames ofncl-content-bullet-{x}
andncl-content-compact-{x}
.ncl-content-bullet
to apply styles to all items with classnames ofncl-content-bullet-{x}
.ncl-content-compact
to apply styles to all items with classnames ofncl-content-compact-{x}
.
例
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.
インストール
- download the last version from githubして、ファイルを
extensions/
フォルダー内のNiceCategoryList3
という名前のディレクトリ内に配置します。 - 以下のコードを LocalSettings.php ファイルの末尾に追加します:
wfLoadExtension( 'NiceCategoryList3' );
- Configure at your convenience.
- 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
設定
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
バージョン履歴
Version 1.1.1 | |