Extension:CategoryTree/ja

CategoryTree拡張機能はウィキのカテゴリ構造の動的なビューをツリーとして提供します. これは必要に応じてツリーの一部をロードするためにAJAXを使います. CategoryTreeは外部ツールとしてもともとはDaniel Kinzlerによって開発されました(meta:User:Duesentrieb/CategoryTreeを参照). のちにこれはTim Starlingの助けによってMediaWikiソフトウェアに統合されました.

使用法
CategoryTreeは3つの方法で使用できます:
 * カテゴリページ内で直接使用する
 * ウィキページでインラインのカテゴリ構造を表示する"カスタムタグ"(または"パーサー関数")
 * 特別ページとして追加する

CategoryTree拡張機能はカテゴリページに一覧が表示される下位カテゴリに ► "expand" ウィジェットを追加します.

&lt;categorytree&gt; タグ
例. 実行結果は下のボックスと右にあります:

カスタムタグは &lt;categorytree&gt; と呼ばれます. たとえば、ウィキページに &lt;categorytree&gt;Foo&lt;/categorytree&gt; を記載すると、そのページでFooカテゴリの内容が動的なツリーとして表示されます (右の例を参照). HTMLライクな構文を使って、タグは次の属性を受け入れます:


 * mode: ツリーに表示されるページを決定します. これは  オプションを使用することでオーバーライドできます. 許可される値は次の通りです:
 * categories: 下位カテゴリだけ表示する(構成定数の )
 * pages: 画像以外の下位カテゴリとページを表示する(構成定数の )、ページ数の上限は200件
 * all: すべてのページ、下位カテゴリ、画像などを表示する(構成定数の )
 * parents: 下位カテゴリの代わりに親カテゴリの一覧を表示する (構成定数の ). これはCategoryTreeに"inverse"オペレーションをさせます(2008年7月の  以降でサポートされます).


 * depth: 最初に表示されるツリーのレベルを決めます. 既定値は1で、0はルートノードのみを意味します. 最大値は指定されるモード、と  オプションに依存します(2007年5月30日の  と  の間に導入されました; 2008年6月の  以降の   でも、十分な機能があります)
 * onlyroot : 初期の状態でツリーの"root"ノードのみを表示するようにするには これを "on" に設定します.  と同等です. (2007年3月13日の  で導入されました) 2008年7月の  は廃止されました: 代わりに   を使用してください.
 * hideroot: ツリーの"root"ノードを隠すにはこれを "on"、すなわち  にセットします. この例ではカテゴリのFooは表示されません.
 * hideprefix: ツリーのエントリから隠される名前空間の接頭辞を決定します(2008年7月の 以降). 可能な値は次の通りです:
 * always: 常に接頭辞を隠します. すべてのページが同じ名前空間に属する場合に使います (構成定数の ).
 * never: カテゴリに対してでも、名前空間の接頭辞を決して隠さない(構成定数の ).
 * auto: カテゴリの名前空間を隠します. カテゴリのみが表示される場合、 と同じです(構成定数の  ). これは古い既定の挙動と同等です(2008年6月以前).
 * categories: カテゴリの名前空間を隠しますが、他のすべての接頭辞を表示します(構成定数の ). これは新しい既定の挙動です(2008年7月の  以降).


 * showcount: 下位カテゴリの数を表示するにはこれを "on"、すなわち  に設定します(2008年7月の  以降). これはページのインラインのカテゴリツリーに対しては既定で無効ですが、カテゴリ一覧および Special:CategoryTree では既定で有効になります.
 * namespaces: a list of namespaces from which pages should be shown in the tree (since, July 2008). The entries in the list must be namespace names, separated by spaces. The main namespace can be represented by "-" or "0". Subcategories will be shown only if Category namespace is present on the list.
 * class, style、id、etc: &lt;categorytree&gt; タグはブロック要素用の標準のすべてのHTML属性をサポートします(2008年7月の  以降で、それ以前は   のみがサポートされました).

Notes on the 'namespaces' parameter
Category is a namespace. Categories are shown in all modes by default, but specifying the  parameter hides them just like any other namespace not present on the list. If you want to list pages in a given namespace, including pages in subcategories, simply add Category to the namespace list.

Example:


 * Listing main namespace pages in Category:Manual:


 * Listing main namespace pages and subcategories in Category:Manual:

The  parameter is overridden by  :
 * if only Category namespace is asked, it's equivalent to ;
 * if file namespace is present on the list, it will imply ;
 * otherwise  will be used. It means that if the site configuration hasn't been changed, the following are equivalent (the first two are always equivalent, the third only if   is the default  ):

The parser function
Since (Sep 13, 2007), you can also use parser function syntax to place a category tree on a page. This works just like the &lt;categorytree&gt; tag, using a different syntax, e.g. ; options can be specified using the syntax for named template parameters, e.g..

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):.
 * Using a template to specify the 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:  in Template:Baz can be called using.

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

Configuration
There are some options you can specify in your file:


 * $wgCategoryTreeMaxChildren: maximum number of children shown in a tree node. Default is 200.
 * $wgCategoryTreeAllowTag: enable &lt;categorytree&gt; tag. Default is true.
 * $wgCategoryTreeDynamicTag: loads the first level of the tree in a &lt;categorytree&gt; dynamically. This way, the cache does not need to be disabled. Default is false.
 * $wgCategoryTreeDisableCache: disables the parser cache for pages with a &lt;categorytree&gt; tag, or provides max cache time in seconds. Default is 21600 which is 6 hours.
 * $wgCategoryTreeUseCache: enable HTTP cache for anon users. Default is false.
 * $wgCategoryTreeOmitNamespace : do not show the namespace name for pages and categories. Default is false, namespaces are shown unless showing categories only. Deprecated as of, July 2008: use  instead.
 * $wgCategoryTreeMaxDepth: an array defining the maximum depth for each mode, to which the tree may be expanded initially using the depth parameter in a &lt;category&gt; tag. By default, this is set to 2 for the "categories" mode, and 1 for other modes. To set it to 3 for categories and 2 for other modes, for example, you can use.
 * $wgCategoryTreeDefaultMode: the default mode to use when no mode attribute is specified in a &lt;categorytree&gt; tag. May be  (the default), , or.
 * $wgCategoryTreeCategoryPageMode : the mode to use when rendering trees on category pages. Deprecated as of, July 2008: use  instead.
 * $wgCategoryTreeForceHeaders: if true, forces the scripts needed by CategoryTree on every page, instead of on-demand. This may be needed if a CategoryTree is embedded in an unusual way, for example in a custom skin or in a system message (since, July 2008).
 * $wgCategoryTreeSidebarRoot: root category to use for integrating the category tree in the sidebar (since, July 2008). If not set, no tree is integrated (this is the default). Integrating a CategoryTree into the sidebar only works with skins based upon SkinTemplate, that is, Modern, Monobook, Chick, Simple, and MySkin, but not Standard, Nostalgia or CologneBlue.
 * $wgCategoryTreeDefaultOptions: default options to apply, as an array (since, July 2008). The available options are described above. Example:.
 * $wgCategoryTreeCategoryPageOptions: options to use on category pages, as an array (since, July 2008).
 * $wgCategoryTreeSpecialPageOptions: options to use on Special:CategoryTree, as an array (since, July 2008).
 * $wgCategoryTreeSidebarOptions: options to use when showing the tree in the sidebar, as an array (since, July 2008)

categorytree-member-num
By default, when listing subcategories on a category page, each subcategory is followed by an integer, indicating how many subcategories lie beneath it, how many pages it contains, and how many files are in the category (if applicable):


 * My category name (5 C, 2 P, 1 F)

You can change this behavior by overriding the system message MediaWiki:Categorytree-member-num. It takes five parameters:

The default value is.

Tip: Use the extension to provide if/then/else logic to display different parts conditionally. For example:

A configuration to manage commas and spaces when outputting all info:

Abbreviation version: 

Full name version: 

Wiki is broken after installing CategoryTree

 * Turn on
 * Make sure you have all files installed
 * Make sure all of the CategoryTree extension files have mode 644, and the CategoryTree directory has mode 755.

Options in LocalSettings.php have no effect

 * Make sure you specify the options after including the extension.

Clicking the ► has no effect, gives a JavaScript error or just sits on loading

 * Note that using the &lt;categorytree&gt; tag in system messages (MediaWiki namespace) may not work as expected - this is a known caveat. For a workaround, see  below.
 * Make sure you have  in your LocalSettings.php before including the extension.
 * Make sure you are using the latest version of the extension - the bleeding edge is at
 * If you are using rewrite rules or aliasing (e.g. to have "very short URLs" - i.e. wiki pages in the document root or perhaps redirecting to a www-version of the requested URL), make sure you have an exception in place for the /extensions directory, just like you would for the /skins directory. Also see below.

Clicking the ► shows no sub-categories error

 * Try to fix this by adding this code to LocalSettings.php:

Browser reports a bad MIME type for CategoryTree.js and/or CategoryTree.css

 * Make sure your web server uses the correct MIME types for .js and .css files
 * Enter the URLs directly into the browser and see if it is serving the pages at all, and not some error page; especially:
 * If you are using rewrite rules or aliasing (e.g. to have "very short URLs" - i.e. wiki pages in the document root), make sure you have an exception in place for the /extensions directory, just like you would for the /skins directory.

Member counts are wrong, grey arrows ► are shown instead of ►
Since MediaWiki 1.13, CategoryTree can show the number of members of a category, and can show a grey arrow ► for tree nodes that do not have any children based on that number. This information is based on the new. However, populating that table with the current values does not always work when upgrading to 1.13. In that case, run the  maintenance script, if necessary with the   option.

► ► ▼ toggles shown only on the first level of the category tree view
In case you get only one level depth while visualing the tree, try to set in modules/ext.categoryTree.styles.css file  to.

The JavaScript intended to switch the tag style is somehow buggy.

Note to bot users
Bots and scripts that parse the HTML of category pages can use the notree URL parameter to force the traditional output. However, HTML output is generally not stable, so it is recommended to change your script to use the to fetch category listings and similar.

"Category Not Found" message
After you implement the CategoryTree plugin and add the code to show the tree, if you see a message that says Category Not Found, you need to add some content in your category pages. The category pages can't be red pages, basically. Click your category names, add some text in the category page, and then your tree should work fine.

Next 200 links do not work with CategoryTree installed
Make sure the right version of this extension is installed, relative to the version of MediaWiki you have installed. In particular, versions of this extension made for versions of MediaWiki prior to 1.17 are not compatible with MediaWiki 1.17 and greater, and will cause issues where all the paging links on category pages are broken.

No pages are shown when using the "namespaces" parameter
See above.

Using CategoryTree in system messages and custom skins
To use the CategoryTree in system messages or the sidebar, that is, to use it as part of the user interface instead of page content, you have to set  to , so that the support scripts are linked on every page (normally, they are only linked "on demand", but that detection does not work for system messages). This works since (July 2008). If you try this without forcing the scripts to be included, you will find that Clicking the ► has no effect, gives a JavaScript error or just sits on loading.

In older versions of CategoryTree, you have to modify the code to make this work: find the  function in the file CategoryTree.php, and remove the condition; i.e. it should then look like this:

Using JavaScript
Since (July 2008) with MediaWiki 1.13, you can integrate a CategoryTree in the sidebar simply by setting   to the category you want to use as a root. This only works with skins based upon SkinTemplate however, that is, Modern, Monobook, Chick, Simple, and MySkin, but not Standard, Nostalgia or CologneBlue.

If you use  in LocalSettings.php to drop your own wikitext article into the Sidebar, and then add CategoryTree items to it, you'll need to set   to ensure that every page works.

If you want the CategoryTree on a different position in the sidebar, you can reference it on MediaWiki:Sidebar as "categorytree-portlet".

For earlier versions of CategoryTree and/or MediaWiki, you'll need to install a mod to MonoBook.php to enable normal wikitext in the sidebar, see --DJ 19:26, 24 January 2008 (UTC)

To append a link "CategoryTree" to your toolbox add following code to the JavaScript page (e.g. monobook.js) of your  and customize the URL "w:en:Special:CategoryTree".

A more generic version of this code can be found at.

Step by step if works easy:
 * Add these lines to :

Using MediaWiki: namespace pages
If you want to create a link that goes to the generic categorytree (displayed as Category tree) when you're on a non-category page, and to a particular categorytree (displayed as View as category tree, with foo being the name of the category you're viewing) when you're on a category page:
 * Add to your MediaWiki:Sidebar (right above the SEARCH is a good place) a line,
 * Create a MediaWiki:Sidebarcategorytree with, say:
 * Create a MediaWiki:Sidebarcategorytree-url with, say:

Parameters to request
It is possible to override the default site configuration of "mode" by providing it to as URL parameter. For example


 * - use default mode
 * - use categories mode
 * - use page mode
 * - use all mode
 * - use parent mode