Module:Navigation by Wikidata/doc

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules

This is the documentation page for Module:Navigation by Wikidata

The module 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 module is wrapped by {{Navigation by/Wikidata}}, which 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 invoke this module directly, but rather use one of these templates instead.

Usage

[edit]
{{#invoke:Navigation by Wikidata|navigationList}}
{{#invoke:Navigation by Wikidata|navigationBlock}}
{{#invoke:Navigation by Wikidata|navigationInline}}
{{#invoke:Navigation by Wikidata|navigationBox}}

Parameters

[edit]

See {{Navigation by/Wikidata}}.

Functions

[edit]
style= Function Result Usage
list navigationList Bullet list of navigation items Raw data for inclusion in a more complex navigation box
block navigationBlock Both a title line and a bullet list of navigation items Navigation part of {{Category description}} templates
box navigationBox Complete navigation box Standalone navigation boxes
inline navigationInline Borderless navigation box Navigation embedded into, for example, a table

When invoked through {{Navigation by/Wikidata}}, the parameter “style” of that template determines which of the functions of this module is called.

Mode of operation

[edit]
[edit]

There are three distinct methods to define the items of which the navigation list should consist:

  • Explicit list of Wikidata item IDs as unnamed (numbered) parameters.
Example: Unnamed parameters Q1314, Q1311, Q1312, and Q1313 produce a navigation for spring, summer, autumn, and winter.
Metatemplates using this method are called “static metatemplates”.
  • Definition of a Wikidata item, a property, and the level “children”. The property is expected to contain references to other Wikidata items, which then are used as the items to navigate through.
Example: item = Q30 (United States) and property = P150 (contains administrative territorial entity) produces a navigation for the states of the U.S.A.
  • Definition of a Wikidata item, a property, optionally a parentproperty, and the level "siblings". First, the parentproperty (or, if that's not set, the inverse property (P1696) of the property) is used to find the “parent” of the given item, and then the list is built from the children of that parent as described in the previous method.
Example: item = Q99 (California), property = P150 (contains administrative territorial entity), and parentproperty = P131 first uses the property located in the administrative territorial entity (P131) to find the "parent item" United States of America (Q30) and then produces a navigation for the states of the U.S.A.
This method is not recommended for building actual navigation templates, but it's used by the Category definition boxes.
Metatemplates using these two methods are called “dynamic metatemplates”. They leave the level parameter to their caller, so they can be used both ways.
[edit]

To build the link targets, a pattern must be provided where the variable part is a placeholder enclosed in << and >>. For each of the items collected as described above, this placeholder gets replaced by the value of the item's Commons category (P373) property.

Example: The Commons category (P373) of Mississippi (Q1494) is “Mississippi (state)”, so with a pattern of Nature of <<state>> the link target will be Category:Nature of Mississippi (state). Therefore it is essential that the categories are named consistently: a category named “Nature of Mississippi” or “Nature of Mississippi, USA” would not appear in the navigation list.

There are some cases where the name of the item consists of more than word, and the words must be connected with a hyphen. The hyphen parameter must be set to “yes” in these cases.

Example: For a pattern like <<century>> bridges, you would set this parameter so for 20th century (Q6927), the link target becomes Category:20th-century bridges (with the hyphen between “20th” and “century”) even though the Commons category (P373) is 20th century without the hyphen.

There are some names which, when used in some patterns, need to be prefixed with a “the”. Module:Navigation by Wikidata/special rules defines a list of Wikidata items for which this is the case, and the the parameter can be set to “yes” when this rule should be applied.

Example: For a pattern like Nature of <<country>>, you would set this parameter so for the United States of America (Q30), the link target will be Category:Nature of the United States, while for the pattern <<country>> in the 1970s, you'd not set it, because the desired link target is Category:United States in the 1970s without any “the” before “United States”.

It is possible that for the title of the navigation list, completely different rules for building the link target apply. In that case, you can use title:pattern, title:hyphen, and title:the to define the diverging rules to use for the title.

Example: With the pattern Bridges completed in <<year>>, the title would be the matching decade category so the title:pattern is <<decade>> bridges.
[edit]

For each item, the label in the user's language is looked up in Wikidata and used as the label. Optionally, the navigation list can be sorted alphabetically by these (translated) labels.

Automatic categorization

[edit]

This module can also automatically add categories on the page it is used. See the autocat group of parameters in the {{Navigation by/Wikidata}} documentation for more information about this.