Template:Navigation by/Wikidata

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Template documentationview · edit · history · purge ]

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:

  1. Forcing a specific non-alphabetic order on the navigation list and/or decorating the items with before and/or after. 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.
  2. 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

ParameterDescriptionDefaultStatus
nameName 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}}.
emptyrequired
titleWikidata item ID for the title. Only used for dynamic metatemplates, and not used for style=list.emptyoptional
aboveText 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.
emptyoptional
belowText 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.
emptyoptional
1, 2, 3...Wikidata item IDs of the navigation items in static metatemplates. Can be decorated with :before=text and/or :after=text.emptyoptional
itemWikidata 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.
emptyoptional
propertyWikidata property ID to use for the list of navigation items in dynamic metatemplates.emptyoptional
parentpropertyWikidata 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.emptyoptional
levelWikidata level to get the navigation items from:
children
the list will be composed directly from the item's property
siblings
the parent of the item will be determined, and the list will be composed from that parent's property
When defining a new metatemplate, use {{{level|}}} to allow the calling template to define this.
emptyoptional
sortsort criterion:
label
sort the list of navigation items by alphabet
If that parameter is left blank, navigation items generated from unnamed or numbered parameters will remain in the order in which they appear in the argument list, and navigation items generated from the item/property/level parameters will remain in the order in which the values appear in the Wikidata statement list.
emptyoptional
title:patternLike 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.
emptyoptional
title:hyphenLike 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.
emptyoptional
title:theLike 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.
emptyoptional
patternName 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.
emptyrequired
hyphenIf 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.
nooptional
theIf 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”.
nooptional
redlinksHow to handle red links to nonexisting category pages:
yes
show red links
no
hide red links
When defining a new metatemplate, use {{{redlinks|yes}}} to allow the calling template to define this and default to “yes”.
nooptional
arrowsIf 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.nooptional
styleDisplay style of the navigation list:
box
standalone navigation box with title and border
inline
a borderless navigation box which can be embedded e.g. in a table
list
just the item list to embed it into a Navbox with several navigations
block
used in {{Category description}} templates
When defining a new metatemplate, use {{{style|box}}} to allow the calling template to define this and default to box.
boxoptional
autocatIf 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.
nooptional
autocat:parentIf 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.
yesoptional
autocat:candidatesCandidates 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.
emptyoptional
autocat:sortkeyWhich value to use as the sortkey for automatically added categories:
catname
the Commons category name of the navigation item matching the current page, before applying any hyphen or the parameters
number4
the first numeric part of the Commons category name of the navigation item matching the current page, filled with as many leading zeroes as it takes to make 4 digits; any other number of digits than 4 works similarly
index
the index of the navigation item within the list, before applying the sort parameter
catnameoptional
autocat:pruneA 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”.emptyoptional
autocat:prefix1A prefix to be added in front the sortkey, after any autocat:prune parameter has been applied. This is used for all automatically added categories.emptyoptional
autocat:prefix2A prefix to be added in front the sortkey, after any autocat:prune parameter has been applied. This is not used for automatically added metacategories.emptyoptional

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.