Va ô cuntinutu

Mòdulu:Bozza/GianAntonucci/Wikidata/doc

Dâ Wikipedia, la nciclupidìa lìbbira.

Chista è la pàggina di ducumintazzioni di Mòdulu:Bozza/GianAntonucci/Wikidata

This module provides a comprehensive interface for accessing and formatting Wikidata content in MediaWiki templates. It supports all major Wikidata data types and offers extensive customization options while following performance best practices.

Note: Unless the from parameter is used, the following examples assume they are being run on a page linked to a Wikidata item. For demonstration purposes, many examples use Douglas Adams (Q42) as a reference.

Basic syntax

[cancia lu còdici]
{{#invoke:Bozza/GianAntonucci/Wikidata|function|parameters}}

Quick examples

[cancia lu còdici]
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P31}}                    → Human
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P569}}                   → 14 April 1972
{{#invoke:Bozza/GianAntonucci/Wikidata|getQualifier|P39|P580}}              → 20 January 2009

getProperty

[cancia lu còdici]

Retrieves and formats property values from Wikidata.

Parameters:

  • 1 or property – Property ID (required)
  • from – Entity ID to get data from (optional, defaults to current page)
  • rank – Which ranks to include (see rank parameter below)
  • formatting – Output format (see data type formatting below)
  • separator – String to join multiple values (default: , )
  • limit – Maximum number of values to return
  • index – Return only the nth value
  • hasqualifier – Only return statements with this qualifier (see filtering parameters)
  • qualifiervalue – Required value for the qualifier (used with hasqualifier)
  • default – Value to return if no data found

Examples:

{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P31}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P31|formatting=label}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P31|from=Q42}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P39|hasqualifier=P580}}

getQualifier

[cancia lu còdici]

Retrieves qualifier values from property statements.

Parameters:

  • 1 or property – Property ID (required)
  • 2 or qualifier – Qualifier ID (required)
  • from – Entity ID (optional, defaults to current page)
  • rank – Which ranks to include (see rank parameter)
  • formatting – How to format the output
  • separator – String to join multiple values (default: , )
  • default – Value to return if no data found

Examples:

{{#invoke:Bozza/GianAntonucci/Wikidata|getQualifier|P39|P580}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getQualifier|P39|P580|separator=<br/>}}

Gets the label of a Wikidata entity.

Parameters:

  • 1 or entity – Entity ID (optional, defaults to current page)
  • 2 or lang – Language code (optional, defaults to wiki language)

Examples:

{{#invoke:Bozza/GianAntonucci/Wikidata|getLabel}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getLabel|Q42}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getLabel|Q42|de}}

getDescription

[cancia lu còdici]

Gets the description of a Wikidata entity.

Parameters:

  • 1 or entity – Entity ID (optional, defaults to current page)
  • 2 or lang – Language code (optional, defaults to wiki language)

Examples:

{{#invoke:Bozza/GianAntonucci/Wikidata|getDescription|Q42}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getDescription|Q42|fr}}

Gets both label and description efficiently.

Parameters:

  • 1 or entity – Entity ID (optional, defaults to current page)
  • 2 or lang – Language code (optional)
  • separator – String between label and description (default: - )

Examples:

{{#invoke:Bozza/GianAntonucci/Wikidata|getTerm|Q42}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getTerm|Q42|separator=: }}

Gets the Wikidata entity ID for a page.

Parameters:

  • 1 or page – Page title (optional, defaults to current page)

Examples:

{{#invoke:Bozza/GianAntonucci/Wikidata|getId}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getId|Douglas Adams}}

Counts the number of statements for a property.

Parameters:

  • 1 or property – Property ID (required)
  • All filtering parameters from getProperty are supported

Examples:

{{#invoke:Bozza/GianAntonucci/Wikidata|count|P50}}
{{#invoke:Bozza/GianAntonucci/Wikidata|count|P50|hasqualifier=P1545}}

Common parameters

[cancia lu còdici]

Formatting parameter

[cancia lu còdici]

The formatting parameter controls how values are displayed:

For entities:

  • raw or id – Returns the entity ID (e.g., Q42)
  • label – Returns only the label
  • sitelink – Returns only the sitelink
  • (default) – Returns a linked label if possible

For other types:

  • raw – Returns unformatted value
  • (default) – Returns formatted value

Rank parameter

[cancia lu còdici]

Controls which statement ranks to include:

  • best – Preferred if available, otherwise normal (default)
  • preferred – Only preferred rank
  • normal – Only normal rank
  • deprecated – Only deprecated rank
  • all – All ranks

Filtering parameters

[cancia lu còdici]
  • hasqualifier – Only include statements with this qualifier
  • qualifiervalue – Required value for the qualifier
  • limit – Maximum number of results
  • index – Select only the nth result

Data type formatting

[cancia lu còdici]

Entities (items and properties)

[cancia lu còdici]
Code Result
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P31|from=Q42}} èssiri umanu
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P31|from=Q42|formatting=label}} èssiri umanu
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P31|from=Q42|formatting=id}} Q5

Quantities

[cancia lu còdici]
Code Result
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P2048|from=Q42}} 1,96 metru
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P2048|from=Q42|unitsymbol=true}} 1,96 metru
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P2048|from=Q42|showunit=false}} 1,96 metru

Dates and times

[cancia lu còdici]
Code Result
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P569|from=Q42}} 11 marzu 1952
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P570|from=Q42}} 11 maju 2001
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P569|from=Q1}}

Different precisions are automatically formatted:

Precision Example output
Day 11 May 2001
Month May 2001
Year 2001
Decade 2000s
Century 21st century
Millennium 3rd millennium

Commons media

[cancia lu còdici]
Code Description
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P18|from=Q42}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P18|from=Q42|size=150px}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P18|from=Q42|thumb|caption=Douglas Adams}}
Douglas Adams
Code Result
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P856|from=Q42}} douglasadams.com
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P856|from=Q42|formatting=raw}} https://douglasadams.com

Coordinates

[cancia lu còdici]
Code Result
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P625|from=Q174373|limit=1}} 9.215, 123.514
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P625|from=Q174373|limit=1|coord=latitude}} 9.215, 123.514
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P625|from=Q174373|limit=1|coord=longitude}} 9.215, 123.514

Monolingual text

[cancia lu còdici]
Code Result
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P1477|from=Q42}} Douglas Noël Adams
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P1477|from=Q42|showlang=true}} Douglas Noël Adams (en)

Advanced features

[cancia lu còdici]

Multiple values

[cancia lu còdici]

Control how multiple values are displayed:

{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P50|separator= / }}
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P50|limit=3}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P50|index=2}}

Qualifier filtering

[cancia lu còdici]

Filter statements by qualifiers:

{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P39|hasqualifier=P580}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P39|hasqualifier=P580|qualifiervalue=2020}}

Using specific entities

[cancia lu còdici]

Access data from entities other than the current page:

{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P31|from=Q42}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getLabel|Q42}}
{{#invoke:Bozza/GianAntonucci/Wikidata|getDescription|Q42}}

Infobox integration

[cancia lu còdici]
{{Infobox person
| name         = {{#invoke:Bozza/GianAntonucci/Wikidata|getLabel}}
| image        = {{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P18|size=250px}}
| birth_date   = {{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P569}}
| birth_place  = {{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P19|formatting=label}}
| occupation   = {{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P106|separator=<br/>}}
}}

Conditional display

[cancia lu còdici]
{{#if: {{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P50}} |
'''Authors:''' {{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P50|separator=, }}
}}

Complex queries

[cancia lu còdici]
Mayor: {{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P6|hasqualifier=P580}}
Term start: {{#invoke:Bozza/GianAntonucci/Wikidata|getQualifier|P6|P580}}
Term end: {{#invoke:Bozza/GianAntonucci/Wikidata|getQualifier|P6|P582}}

Performance considerations

[cancia lu còdici]
  1. Efficient API usage: The module uses getBestStatements and getAllStatements instead of getEntity, which is much more memory-efficient.
  2. Lazy loading: Data is only fetched when needed, not preloaded.
  3. Caching: MediaWiki caches Wikidata access, so repeated calls to the same property are efficient.
  4. Filtering: The module filters data as early as possible to minimize processing.

Error handling

[cancia lu còdici]

The module provides clear error messages:

  • Property not provided – Shown when the property parameter is missing
  • Qualifier not provided – Shown when the qualifier parameter is missing
  • Entity not found – Shown when the specified entity doesn't exist
  • Unknown data type – Shown for unsupported Wikidata types
  • Unknown entity type – Shown for unrecognised entity types

Errors are wrapped in <span class="error"> tags and can trigger categorization in mainspace.

Suppressing errors

[cancia lu còdici]

Use the default parameter to provide fallback text:

{{#invoke:Bozza/GianAntonucci/Wikidata|getProperty|P999|default=No data available}}