Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Kiterjesztés:CategoryTree

From mediawiki.org
This page is atranslated version of the pageExtension:CategoryTree and the translation is 13% complete.
Outdated translations are marked like this.
Languages:
MediaWiki-kiterjesztések kézikönyve
CategoryTree
Kiadási állapot: stabil
MegvalósításTag,Parser function,Speciális lap
LeírásLehetővé teszi a kategóriák fastruktúra szerinti dinamikus megjelenítését
Szerző(k)Daniel Kinzler (Duesentriebvitalap)
Legfrissebb verziófolyamatos frissítés
Kompatibilitási irányelvSnapshots releases along with MediaWiki.Master is not backward compatible.
MediaWiki1.25+
LicencGNU General Public License 2.0 or later
Letöltés
OLVASS EL
  • $wgCategoryTreeAllowTag
  • $wgCategoryTreeCategoryPageOptions
  • $wgCategoryTreePageCategoryOptions
  • $wgCategoryTreeMaxDepth
  • $wgCategoryTreeSidebarOptions
  • $wgCategoryTreeDefaultOptions
  • $wgCategoryTreeMaxChildren
  • $wgCategoryTreeSpecialPageOptions
  • $wgCategoryTreeOmitNamespace
  • $wgCategoryTreeSidebarRoot
  • $wgCategoryTreeUseCategoryTable
  • $wgCategoryTreeCategoryPageMode
  • $wgCategoryTreeDefaultMode
  • $wgCategoryTreeDisableCache
  • $wgCategoryTreeHijackPageCategories
Fordítsd le a(z) CategoryTree kiterjesztést, ha elérhető a translatewiki.net oldalon
ProblémákNyitott feladatok ·Hibajelentés

ACategoryTree kiterjesztés lehetővé teszi a wiki kategóriáinak fastruktúra szerinti dinamikus megjelenítését. A kiterjesztés a kategóriák betöltéséhezAjaxot használ. A CategoryTree eredeti szerzője Daniel Kinzler; a külső eszköz később Tim Starling segítségével a MediaWiki része lett.

Telepítés

Ezt a kiterjesztést aMediaWiki 1.31 és afölötti verziói már tartalmazzák, így nem kell újra letöltened.The remaining configuration instructions must still be followed.
  • Töltsd le a kiterjesztés fájljait, és mentsd el azextensions/ mappán belüliCategoryTree könyvtárba.
    Developers and code contributors should install the extensionfrom Git instead, using:
    cdextensions/gitclonehttps://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
  • Add hozzá az alábbi kódot aLocalSettings.php fájlod aljára:
    wfLoadExtension('CategoryTree');
  • YesKész – ASpecial:Version oldalon ellenőrizheted, hogy a kiterjesztés ténylegesen feltelepült-e.

Használat

A CategoryTree használati módjai:

  • a kategóriák lapján
  • egyedi címkeként (vagy értelmezőfunkcióként) a kategóriák wikilapon történő megjelenítéséhez
  • speciális lapként

A kiterjesztés a kategóriák lapján szereplő alkategóriák címe mellett egy kibontás gombot helyez el.

A <categorytree> címke

Az alábbi dobozban és a jobb oldali listában láthatod a kiterjesztést működés közben:

<categorytreemode="pages">Manual</categorytree>


Ha például elhelyezed a $code sort egy wikilapon, akkor a Foo kategória fastruktúra szerint fog megjelenni (lásd jobbra). A címke a következő HTML-stílusú attribútumokkal konfigurálható:For example, if you put <categorytree>Foo</categorytree> on a wiki page, it will show the contents of category Foo as a dynamic tree on that page (see example to the right).The tag accepts the following attributes, using a HTML-like syntax:

mode
meghatározza a fán megjelenő lapokat, ez anamespaces kapcsolóval írható felül; lehetséges értékei:
categories
csak az alkategóriák mutatása (0 konfigurációs konstans)
pages
alkategóriák és lapok mutatása a képek kivételével (10 konfigurációs konstans), maximum 200 lap
all
minden lap, alkategória, kép stb. mutatása (20 konfigurációs konstans)
parents
szülőkategóriák mutatása az alkategóriák helyett (100 konfigurációs konstans); ez a kiterjesztést inverz módba kapcsolja (2008 júliusa (r36892) óta támogatva)
depth
determines how many levels of the tree are shown initially. Default is 1. 0 means only the root node. The maximum value depends on the mode specified, and on the$wgCategoryTreeMaxDepth option. (Introduced betweenr20410 andr20840, Mar 30 2007; fully functional even with$wgCategoryTreeDynamicTag sincer36864, July 2008.)
onlyroot
set this to "on" to only show the "root" node of the tree initially. Equivalent todepth="0".(Introduced inr20385, March 13 2007.) Deprecated as ofr36864, July 2008: usedepth="0" instead.
hideroot
set this to "on" to hide the "root" node of the tree, i.e.hideroot=on. For example, it will not display the category name Foo.
hideprefix
determines when the namespace prefix should be hidden from entries in the tree (sincer36864, July 2008). Possible values are:
always
always hide the prefix. Should be used only if all pages come from the same namespace (configuration constant10).
never
never hide the namespace prefix, not even for categories (configuration constant0).
auto
hide the namespace of categories if only categories are shown, as withmode="categories" (configuration constant30). This is equivalent to the old default behavior (before Jun 2008).
categories
always hide the namespace of categories, but show all other prefixes (configuration constant20). This is the new default behavior (sincer36864, July 2008).
showcount
set this to "on" to show the number of entries in subcategories, i.e.showcount="on" (sincer36864, July 2008).This is disabled per default for category trees inlined on pages, but enabled per default in category listings and on Special:CategoryTree.
notranslations
set this to "on" to hide all translations pages corresponding to the pages pertaining to the category, i.e.notranslations="on" (sinceGerrit change 526234, November 2019).This is disabled by default.If this option is set to "on", instead of the different translations (e.g. Page, Page/en, Page/fr, Page/de) only the standard translation "Page" is displayed and all translations are suppressed.
This doesn't affect "showcount", so still a bug.
namespaces
a list of namespaces from which pages should be shown in the tree (sincer36864, 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
The‎<categorytree> tag supports all standard HTML attributes for block elements (sincer36864, July 2008; before that, onlystyle was supported).

Notes on the 'namespaces' parameter

Category is a namespace.Categories are shown in all modes by default, but specifying thenamespaces 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:

  • A Kategória:Kézikönyv fő névtérbeli lapjainak listázása:
<categorytreemode="pages"namespaces="Main">Manual</categorytree>
  • Listing main namespace pagesand subcategories in Category:Manual:
<categorytreemode="pages"namespaces="Main Category">Manual</categorytree>

Themode parameter is overridden bynamespaces:

  • if only Category namespace is asked, it's equivalent tomode=categories;
  • if file namespace is present on the list, it will implymode=all;
  • otherwisemode=pages 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$wgCategoryTreeDefaultMode is the defaultCategoryTreeMode::CATEGORIES):
<categorytreemode="categories">Manual</categorytree><categorytreenamespaces="Category">Manual</categorytree><categorytree>Manual</categorytree>

The {{#categorytree}} parser function

Sincer25825 (Sep 13, 2007), you can also useparser function syntax to place a category tree on a page. This works just like the <categorytree> tag, using a different syntax, e.g.{{#categorytree:Foo}}; options can be specified using the syntax for named template parameters, e.g.{{#categorytree:Foo|hideroot|mode=pages}}.

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 showthis page's category tree (may be useful on category description pages):{{#categorytree:{{PAGENAME}}}}.
  • Using a template to specify the category:{{#categorytree:{{root 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:{{#categorytree:{{{1}}}}} in Template:Baz can be called using {{Baz|Foo}}.

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 yourLocalSettings.php file.

Többé nem használhatók a LocalSettings.php-ben a CT_* konstansok.Instead use0 for category mode,10 for pages,20 for all,100 for parents.
$wgCategoryTreeMaxChildren
maximum number of children shown in a tree node. Default is 200.
$wgCategoryTreeAllowTag
enable <categorytree> tag. Default is true.
$wgCategoryTreeDynamicTag
loads the first level of the tree in a <categorytree> dynamically. This way, the cache does not need to be disabled. Default is false.
$wgCategoryTreeDisableCache
disables the parser cache for pages with a <categorytree> 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 ofr36864, July 2008: use$wgCategoryTreeDefaultOptions['hideprefix'] instead.
$wgCategoryTreeMaxDepth
an array defining the maximum depth for eachmode, to which the tree may be expanded initially using the depth parameter in a <category> 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$wgCategoryTreeMaxDepth=[10=>2,20=>2,0=>3,100=>2];.
$wgCategoryTreeDefaultMode
the default mode to use when no mode attribute is specified in a <categorytree> tag. May be0 (the default - categories),10 (pages), or20 (all).
$wgCategoryTreeCategoryPageMode
the mode to use when rendering trees on category pages. Deprecated as ofr36864, July 2008: use$wgCategoryTreeCategoryPageOptions['mode'] instead.
$wgCategoryTreeSidebarRoot
root category to use for integrating the category tree in the sidebar (sincer36920, 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.This is currently broken for MediaWiki 1.35.1 and the vector skin, seephab:T278306.
$wgCategoryTreeDefaultOptions
default options to apply, as an array (sincer36864, July 2008). The availableoptions are described above. Example:$wgCategoryTreeDefaultOptions['mode']='pages';.
$wgCategoryTreeCategoryPageOptions
options to use on category pages, as an array (sincer36864, July 2008).
$wgCategoryTreeSpecialPageOptions
options to use on Special:CategoryTree, as an array (sincer36864, July 2008).
$wgCategoryTreeSidebarOptions
options to use when showing the tree in the sidebar, as an array (sincer36920, July 2008)


System messages

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 messageMediaWiki:Categorytree-member-num. It takes five parameters:

ParameterMeaning
$1Number of subcategories
$2Number of articles (not including category pages or file pages)
$3Number of uploaded files
$4Total number of member pages, including category pages and file pages
$5Something close to ($1 C, $2 P, $3 F) but with anything that is 0 omitted.

More precisely, a comma separated list of the number of pages (mediawiki:categorytree-num-pages), subcategories (mediawiki:categorytree-num-categories), and files (mediawiki:categorytree-num-files) in the category, or empty (mediawiki:categorytree-num-empty) in the case the category has no members. In versions prior to those around 1.19 this value was different. Seeolder version of these docs.

The default value is($5).

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

{{#ifeq:$1|0||$1 categories}}

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

Abbreviation version:

({{#ifeq:$4|0|empty|{{#ifeq:$1|0||$1 C{{#ifeq:{{#expr:$3+$2}}|0||,}}}} {{#ifeq:$2|0||$2 P{{#ifeq:$3|0||,}}}} {{#ifeq:$3|0||$3 F}}}})

Full name version:

({{#ifeq:$4|0|empty|{{#ifeq:$1|0||$1 categories{{#ifeq:{{#expr:$3+$2}}|0||,}}}} {{#ifeq:$2|0||$2 pages{{#ifeq:$3|0||,}}}} {{#ifeq:$3|0||$3 files}}}})

Troubleshooting

Wiki is broken after installing CategoryTree

  • Turn onerror reporting
  • Make sure you have all files installed
  • Make sure all of the CategoryTree extension files havemode 644, and the CategoryTree directory has mode 755.

Options in LocalSettings.php have no effect

  • Make sure you specify the optionsafter including the extension.

Clicking the has no effect, gives a JavaScript error or just sits onloading

  • Note that using the <categorytree> tag in system messages (MediaWiki namespace) may not work as expected - this is a known caveat. For a workaround, seeUsing CategoryTree in the Sidebar below.
  • Make sure you have$wgUseAjax=true; in your LocalSettings.phpbefore including the extension.
  • If you are usingrewrite 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 showsno sub-categories error

  • Try to fix this by adding this code to LocalSettings.php:$wgCategoryTreeDefaultOptions['namespaces']=[0,NS_CATEGORY,NS_FILE];

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 usingrewrite 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 newcategory table. However, populating that table with the current values does not always work when upgrading to 1.13. In that case, run thepopulateCategory.php maintenance script, if necessary with the--force 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 filedisplay:none; todisplay:inline!important;.

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 thenotree URL parameter to force the traditional output. However, HTML output is generally not stable, so it is recommended to change your script to use theAPI 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 saysCategory 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

Seeabove.

Hacks

Using CategoryTree in system messages and custom skins

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

functionefCategoryTreeParserOutput(&$outputPage,&$parserOutput){CategoryTree::setHeaders($outputPage);returntrue;}

Using CategoryTree in the Sidebar

Using JavaScript

Sincer36920 (July 2008) with MediaWiki 1.13 (r36917), you can integrate a CategoryTree in the sidebar simply by setting$wgCategoryTreeSidebarRoot 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 want the CategoryTree on a different position in the sidebar, you can reference it onMediaWiki: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, seeWikitext in side bar --DJ 19:26, 24 January 2008 (UTC)

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

functionAppendCategoryTreeToSidebar(){try{varnode=document.getElementById("p-tb").getElementsByTagName('div')[0].getElementsByTagName('ul')[0];varaNode=document.createElement('a');varliNode=document.createElement('li');aNode.appendChild(document.createTextNode('CategoryTree'));aNode.setAttribute('href','[[w:Special:CategoryTree]]');liNode.appendChild(aNode);liNode.className='plainlinks';node.appendChild(liNode);}catch(e){// lets just ignore what's happenedreturn;}}addOnloadHook(AppendCategoryTreeToSidebar);

A more generic version of this code can be found atManual:Interface/Sidebar#content of sidebar and toolbox (javascript).

Step by step if works easy:

$wgCategoryTreeSidebarRoot='Category:article_name';

Using MediaWiki: namespace pages

If you want to create a link that goes to the generic categorytree (displayed asCategory tree) when you're on a non-category page, and to a particular categorytree (displayed asView as category tree, with foo being the name of the category you're viewing) when you're on a category page:

  • Add to yourMediaWiki:Sidebar (right above the SEARCH is a good place) a line,** sidebarcategorytree-url|sidebarcategorytree
  • Create a [[MediaWiki:Sidebarcategorytree]] with, say:{{#ifeq: {{NAMESPACE}}|Category|View as category tree|Category tree}}
  • Create a [[MediaWiki:Sidebarcategorytree-url]] with, say:{{#ifeq: {{NAMESPACE}}|Category|Special:CategoryTree/{{BASEPAGENAME}}|Special:CategoryTree/Categories}}

See also

Ezt a kiterjesztést egy vagy többWikimédia-projekt használja. Ez valószínűleg azt jelenti, hogy stabil és nagy biztonsággal használható ilyen forgalmas oldalakon is. A kiterjesztést használó wikik pontos listáját a WikimédiaCommonSettings.php ésInitialiseSettings.php konfigurációs fájljaiban a nevére keresve találhatod meg. Egy adott wikin telepített összes kiterjesztés listája a wikiSpecial:Version oldalán található.
Ezt a kiterjesztést az alábbi wikifarmok/szerverek és/vagy csomagok használják:
Retrieved from "https://www.mediawiki.org/w/index.php?title=Extension:CategoryTree/hu&oldid=8040620"
Categories:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp