Template:Navigation by/Wikidata
A metatemplate for category navigation boxes populated from Wikidata
Usage
{{Navigation by/Wikidata
|name =
|title =
|above =
|below =
|1, 2, 3... =
|item =
|property =
|parentproperty =
|level =
|sort =
|pattern =
|redlinks =
|style =
|autocat =
|autocat:parent =
|autocat:candidates =
}}
The template Navigation by/Wikidata facilitates the creation of category navigation boxes which are populated from Wikidata. The text displayed in the resulting navigation boxes will be derived from Wikidata labels in the user's language, so they will be fully translated into all languages available in Wikidata. At the same time, output is formatted using the standard {{Navbox}} template, which means that the navigation boxes are nestable and consistent in design.
This template is used by the Navigation by/criterion family of metatemplates, which in turn serve as a basis for the Navigation by criterion family of navigation boxes as well as for the navigation part of the {{Category description}} boxes. Do not use this template directly on a category page, but rather use one of those derived templates instead.
The only occasion where you should actually use this template directly is when you create a new metatemplate of the form Navigation by/criterion
, providing navigation by a previously unsupported criterion:
Creating a new metatemplate
A category navigational metatemplate can either be static (meaning that there is a fixed list of navigation items) or dynamic (meaning that the navigation items are determined from Wikidata).
Static metatemplates
To create a new static metatemplate, you create a new template following the naming scheme Navigation by/criterion
with the following content:
<includeonly><onlyinclude>{{Navigation by/Wikidata | name = {{subst:PAGENAME}} | title = Wikidata ID of title item | above = {{{above|}}} | below = {{{below|}}} | 1 = Wikidata ID of first navigation item | 2 = Wikidata ID of second navigation item | 3 = Wikidata ID of third navigation item, etc. | level = {{{level|}}} | sort = label (only if you want the items to be alphabetically sorted) | pattern = {{{pattern|<<criterion>>}}} | redlinks = {{{redlinks|yes}}} | style = {{{style|box}}} | autocat = {{{autocat|}}} | autocat:candidates = {{{autocat:candidates|}}} }}</onlyinclude></includeonly>{{Documentation|content={{Navigation by/metatemplatedoc}}}} [[Category:Category navigational metatemplates|Criterion]]
Everything except for the marked placeholders must be copied verbatim.
See the parameter list below for some optional additional parameters, and {{Navigation by/month}} for an example for a static metatemplate.
Dynamic metatemplates
To create a new dynamic metatemplate, you create a new template following the naming scheme Navigation by/criterion
with the following content:
<includeonly><onlyinclude>{{Navigation by/Wikidata | name = {{subst:PAGENAME}} | above = {{{above|}}} | below = {{{below|}}} | item = {{{item|}}} | property = Wikidata property ID to use for compiling the navigation list | parentproperty = Wikidata property ID to find the parent of the current item | level = {{{level|}}} | sort = label (only if you want the items to be alphabetically sorted) | pattern = {{{pattern|<<criterion>>}}} | redlinks = {{{redlinks|yes}}} | style = {{{style|box}}} | autocat = {{{autocat|}}} | autocat:parent = {{{autocat:parent|}}} | autocat:candidates = {{{autocat:candidates|}}} }}</onlyinclude></includeonly>{{Documentation|content={{Navigation by/metatemplatedoc}}}} [[Category:Category navigational metatemplates|Criterion]]
Everything except for the marked placeholders must be copied verbatim.
See the parameter list below for some optional additional parameters, and {{Navigation by/administrative division}} for an example for a dynamic metatemplate.
Explicit item lists
Even though dynamic metatemplates usually compile the list of navigation items directly from Wikidata, that can be overruled for specific base items by creating a template named Navigation by/criterion/base item ID
which yields whatever should end up as the navigation list. This is especially useful for the following two purposes:
- Forcing a specific non-alphabetic order on the navigation list and/or decorating the items with
before
and/orafter
. See {{Navigation by/administrative division/Q1741}} for an example how the districts of Vienna (Q1741) are prefixed with roman numbers and sorted by that number. - Splitting the navigation items in two or more parts with a child {{Navbox}}. See {{Navigation by/administrative division/Q34713}} for an example how the quarters of Salzburg (Q34713) are split into “Stadtteile” (urban quarters) and “Landschaftsräume” (rural quarters) according to an officially used distinction.
Template parameters
Parameter | Description | Default | Status | |
---|---|---|---|---|
name | Name of the template. Only used for the “V·T·E” links with style=box , and to find explicit item lists.When defining a new metatemplate, use {{subst:PAGENAME}} . | empty | required | |
title | Wikidata item ID for the title. Only used for dynamic metatemplates, and not used for style=list . | empty | optional | |
above | Text to output above the actual navigation list. Only used for style=box .When defining a new metatemplate, use {{{above|}}} to allow the calling template to define this. | empty | optional | |
below | Text to output below the actual navigation list. Only used for style=box .When defining a new metatemplate, use {{{below|}}} to allow the calling template to define this. | empty | optional | |
1, 2, 3... | Wikidata item IDs of the navigation items in static metatemplates. Can be decorated with :before=text and/or :after=text . | empty | optional | |
item | Wikidata item ID to use as a starting point for the list of navigation items in dynamic metatemplates. When defining a new dynamic metatemplate, use {{{item|}}} to allow the calling template to define this. | empty | optional | |
property | Wikidata property ID to use for the list of navigation items in dynamic metatemplates. | empty | optional | |
parentproperty | Wikidata property ID to find the item 's parent in dynamic metatemplates. Defaults to the inverse property (P1696) of the property parameter. Only used for level=siblings . | empty | optional | |
level | Wikidata level to get the navigation items from:
{{{level|}}} to allow the calling template to define this. | empty | optional | |
sort | sort criterion:
item /property /level parameters will remain in the order in which the values appear in the Wikidata statement list. | empty | optional | |
title:pattern | Like pattern (see below), but used for the title item. This allows the title item to have a different pattern from the navigation items.When defining a new metatemplate where you want to use this feature, use {{{title:pattern|}}} to allow the calling template to define this. | empty | optional | |
title:hyphen | Like hyphen (see below) in the case that title:pattern is used.When defining a new metatemplate where you want to use this feature, use {{{title:hyphen|}}} to allow the calling template to define this. | empty | optional | |
title:the | Like the (see below) in the case that title:pattern is used.When defining a new metatemplate where you want to use this feature, use {{{title:the|}}} to allow the calling template to define this. | empty | optional | |
pattern | Name pattern for the links to which the navigation items will point. Any variable enclosed in << and >> will be replaced by the correct link target.When defining a new metatemplate, use {{{pattern|<<criterion>>}}} to allow the calling template to define this and set the default to the actual Commons categories. | empty | required | |
hyphen | If this parameter is set to yes , the name of all navigation items will be changed by replacing blanks by hyphens. For example, “20th century” will become “20th-century”.When defining a new metatemplate where you want to use this feature, use {{{hyphen|}}} to allow the calling template to define this. | no | optional | |
the | If this parameter is set to yes , the name of some navigation items (as defined in Module:Navigation by Wikidata/special rules) will be prefixed with a “the”. For example, “Netherlands” will become “the Netherlands”.When defining a new metatemplate where you want to use this feature, use {{{the|yes}}} to allow the calling template to define this and default to “yes”. | no | optional | |
redlinks | How to handle red links to nonexisting category pages:
{{{redlinks|yes}}} to allow the calling template to define this and default to “yes”. | no | optional | |
arrows | If this parameter is set to yes , the Wikidata properties follows (P155) and followed by (P156) of the first/last item will be used to create arrows with links to the previous/next item at the beginning and end of the navigation list. | no | optional | |
style | Display style of the navigation list:
{{{style|box}}} to allow the calling template to define this and default to box . | box | optional | |
autocat | If this parameter is set to yes , the template will automatically add categories to the page. This is only used via the {{Category description}} templates.When defining a new metatemplate, use {{{autocat|}}} to allow the calling template to define this. | no | optional | |
autocat:parent | If this parameter is set to no , the parent category for dynamic metatemplates will be suppressed when automatically adding categories.When defining a new metatemplate, use {{{autocat:parent|}}} to allow the calling template to define this. | yes | optional | |
autocat:candidates | Candidates for the automatically added categories, in the format as described at Module:Autocat. Note that for dynamic metatemplates, the parent category will always be included in the candidates additionally to the ones defined by this parameter (unless suppressed with autocat:parent=no ).When defining a new metatemplate, use {{{autocat:candidates|}}} to allow the calling template to define this. | empty | optional | |
autocat:sortkey | Which value to use as the sortkey for automatically added categories:
| catname | optional | |
autocat:prune | A list of terms, separated by a semicolon (; ), to be purged from the beginning of the sortkey. For example, setting this to Province of;Metropolitan city of will turn the sortkey “Province of Trieste” into just “Trieste” and “Metropolitan city of Palermo” into just “Palermo”. | empty | optional | |
autocat:prefix1 | A prefix to be added in front the sortkey, after any autocat:prune parameter has been applied. This is used for all automatically added categories. | empty | optional | |
autocat:prefix2 | A prefix to be added in front the sortkey, after any autocat:prune parameter has been applied. This is not used for automatically added metacategories. | empty | optional |
Additional information
The template is intended to be used in the following namespaces: the Template namespace
The template is intended to be used by the following user groups: all users
Relies on:
Examples
{{Navigation by/Wikidata|title=Q24384|Q1311|Q1312|Q1313|Q1314|pattern=<<season>> in Europe}}
renders as:
{{Navigation by/Wikidata|item=Q30|property=P150|level=children|sort=label|pattern=Mountains of <<state>>|the=yes|redlinks=yes}}
renders as:
See also
Localization
This template is localized by utilizing Wikidata, via {{Label}} template or similar approach.