แม่แบบ:วิกิสนเทศ/doc

This  is intended to fetch data from Wikidata with or without a link to the connected Wikipedia article and with many other features. {}

**การใช้งาน**

**Commands**
The commands (command1, command2, ...) determine what kind of values are returned. One call can only contain commands from a single class, except that the main class is always used together with one other class.

**Claim class**
The claim class commands can be combined, meaning that multiple commands of different types from this class can be given at one time.
Combine multiple commands into one call to this , instead of making multiple calls to this  with one command each, to be sure that all the returned pieces of information belong to each other.
}}|property|P1|{}}}
Returns the requested property – or list of properties – from the current item-entity or from a given entity.
properties
all matches

II
qualifier
first matchname=fmc

Returns the requested qualifier – or list of qualifiers – from the given property of the current item-entity or of a given entity.
Unlike the other claim class commands, this command can be given multiple times to retrieve different qualifiers in one call.
qualifiers
all matches

III
reference
first matchname=fmc

Returns a reference – or list of references – from the given property of the current item-entity or of a given entity.
references
all matches



**General class**
The general class commands cannot be combined.
}}|label|{}}}
Returns the label of the current item-entity or of a given entity if present.
II
title

Returns the title of the page linked to the current item-entity or to a given item-entity if such page exists.
III
description

Returns the description of the current item-entity or of a given entity if present.
IV
alias
first matchname=fmg

Returns an alias – or list of aliases – of the current item-entity or of a given entity if present.
aliases
all matches

V
badge
first matchname=fmg

Returns a badge – or list of badges – for the page linked to the current item-entity or to a given item-entity if such page exists.
badges
all matches


{}

**Flags**
The following (optional) flags are available which can be used to alter this 's behaviour. They must be given after the (first) command and before the other arguments. For convenience, empty flags (i.e. 
) are allowed and will simply be ignored.

**Command flags**
These flags (flag1*, flag2*, ...) apply to the command that precedes them directly.

**Configuration flags**
These flags (flag0*) are general configuration flags and can be given anywhere after the first command (but before the other arguments).

**Arguments**
The arguments determine the sources from which all the returned values are fetched.

**Positional arguments**
The following table shows the available positional arguments (arg*) in their fixed order. For each command, the applicable set of arguments is marked. If multiple commands are given, then the applicable set is the union of the individual sets. For instance, if the commands properties and qualifiers have been given, then at least both the arguments property_id and qualifier_id should be given as well.
More than one qualifier/qualifiers command can be given. The order in which these commands with their flags are given matches the order in which the respective qualifier_id arguments are given.
}}
commands
flags
entity_id
property_id
raw_value
qualifier_id
qualifier_id

label, title,description,alias/aliases,badge/badges
property/properties
reference/references
qualifier/qualifiers
qualifier/qualifiers (optional 2nd, 3rd, etc.)
Below follows a description of all positional arguments.

**Named arguments**
Below follows a description of all named arguments, which are name-value pairs (i.e. |name=value). These are all optional and can be given anywhere inside the call.

**Property aliases**
Property aliases are other names for P-identifiers that can be used instead. The following property aliases (which are case-sensitive) are currently available:

**References**
When either the reference or the references command is used and a reference is encountered (in Wikidata), the module attempts to display it using the Cite web template. The reference to be displayed has to have at least P1476 and P854 properties. The below table shows the mapping of Wikidata properties to parameters of Cite web.
The following properties are ignored: P18, P143, P3452, P3865, P4656.
If there is no P854 property present in the reference, but a property of the "External identifier" data type is present both in the reference and in the 1687 of the item in P248, a URL is generated from its content and is used in the same manner as a URL given in P854.
If a P1476 or a P854 property is missing or the reference has unknown properties, the module attempts to display it using the Cite Q template. The P248 property is needed. It's used for the first (unnamed) parameter of Cite Q. The below table shows the mapping of other properties to Cite Q parameters.
The properties listed under the first table (in this section) are also ignored when using Cite Q.
A reference could be displayed using Cite Q only if the reference has a P248 property and has only properties listed in the table above. If neither Cite web nor Cite Q could be used to display a reference, the following error is returned:

ผิดพลาด: ไม่สามารถแสดงข้อมูลอ้างอิงได้อย่างถูกต้อง ดูคู่มือการใช้งานสำหรับรายละเอียด

To fix this error, check if the reference has the required properties and doesn't have any unknown properties, as described above. The Wikidata help page on references can also be helpful when sourcing statements.
Note for users copying this template/module to another wiki: The local names of the Cite web and Cite Q templates are fetched from the sitelinks of the Q5637226 or the  Q22321052 item, respectively. If the local citation template isn't linked from its Wikidata item or it doesn't exist at all, this module skips attempting to display citations using it.

**Advanced usage**
The layout of the output from (a combination of) commands that have both a singular and a plural form (e.g. property/properties) can be customized by using a number of named flags, which are name-value pairs (i.e. |flag=value), that can be given anywhere inside the call. The table below shows the available named flags.
To insert a space at the beginning or end of a value, use an underscore _. To get a literal underscore, escape it by placing a backslash \ directly in front of it (i.e. \_); the same holds for a literal backslash (i.e. \\). To get a literal vertical bar |, use ! or &#124;.
Optional parameters can be given by encapsulating them between square brackets: .... All content between the square brackets is only displayed if a value for each optional parameter that has been defined between the same brackets has been found. Optional content can also be nested.
To use two opening square brackets that directly follow each other (i.e. ), use !((.
At least one parameter must be given that is not optional, while the %s parameter must always be defined as optional.
To get a literal , , % or \, escape the character by placing a backslash \ directly in front of it (e.g. \%). See also the description directly above this table for more.
%q%s%r
if the property/properties command was not given and the qualifier/qualifiers command was given
%r
if only the reference/references command was given

if the property/properties command was given and the qualifier/qualifiers command was given
%a%s
if the alias/aliases command was given
%b%s
if the badge/badges command was given
sep=
title=space
default
The fixed separator between each pair of claims.

if only the reference/references command was given without the raw flag
sep%s=
,
default
The movable separator between each pair of claims. This will be the value of the %s parameter applied to all claims except for the last in the list.
;
if the property/properties command was not given and the qualifier/qualifiers command was given
sep%q1=, sep%q2=, sep%q3=, ...
title=comma space
default
The separator between each pair of qualifiers of a single claim. These are the value separators for the %q1, %q2, %q3, ... parameters.
If only one qualifier/qualifiers command was given, then the sep%q1 flag is equivalent to sep%q.
sep%q=
title=comma space
if exactly one qualifier/qualifiers command was given
The separator between each set of qualifiers of a single claim. This is the value separator for the %q parameter.
If only one qualifier/qualifiers command was given, then this flag is equivalent to sep%q1.

if more than one qualifier/qualifiers command was given
sep%r=

default
The separator between each pair of references of a single claim. This is the value separator for the %r parameter.
title=space
if the raw flag was given for the reference/references command
punc=

default
A punctuation mark placed at the end of the output. This will be placed on the %s parameter applied to the last claim in the list.
This allows any references to be placed after the punctuation mark when the output is used as part of a sentence.

**Examples**
}}|label|Q55|fetch=true}}", P395ความ = ""
↓
string

↓

Gets a literal string value.
P395 = ""
↓
string

↓

If the  is transcluded on the  page (which is linked to Q55), then the Q55 can be omitted.
Q55 = "", P395 = ""
↓
string

↓

An entity-ID can also be given using the eid= argument.
Q55 = "", P395 = ""
↓
string

↓

Adds a clickable icon that may be used to edit the returned value on Wikidata.
Q55 = "", P395 = ""
↓
string

↓

Places the edit icon at the end of the line.
Q55 = "", P1082 = ""
↓
quantity

↓

Gets a single property value from claims with a 'normal' rank or higher.
Q55 = "", P1082 = ""
↓
quantity

↓

Gets multiple property values from claims with a 'normal' rank or higher.
Q55 = "", P1082 = "", P585 = ""
↓
quantity, time

↓

Gets a single qualifier value for each claim, additional to the property value.
Q55 = "", P1082 = "", P585 = ""
↓
quantity, time, reference

↓

Gets references for each claim.
Q55 = "", P1082 = ""
↓
quantity, reference
A total of  people live in the Netherlands.
↓
A total of  people live in the Netherlands.
Gets a property with its references.
Q55 = "", P1082 = ""
↓
quantity, reference
The Netherlands has a population of 
↓
The Netherlands has a population of 
Adds a punctuation mark at the end of the output, in front of the references.
Q55 = "", P1082 = "", P585 = ""
↓
quantity, time, reference

↓
Returns the output in a custom format.
Q55 = "", P1082 = "", P585 = ""
↓
time

↓

Gets a single qualifier per claim, by default for multiple matching claims.
Q55 = "", P1082 = "", P585 = ""
↓
time

↓

To get a single qualifier for only a single claim, give the single flag too so that only a single claim will be accessed.
Q55 = "", P1082 = "", P585 = ""
↓
time

↓

Gets a qualifier from claims for which the (raw) property value matches a given literal value.
Q55 = "", P1082 = "", P585 = ""
↓
time

↓

Gets dates in month-day-year order.
Q55 = "", P1082 = "", P585 = ""
↓
time

↓

Gets a raw date value.
Q55 = "", P1082 = ""
↓
reference

↓

Gets the references from a particular claim.
Q55 = "", P1082 = ""
↓
reference

↓

Gets references from a particular claim in their raw form.
Q55 = "", P1081 = ""
↓
quantity, reference

↓

Gets properties from each claim with any references they have.
Q55 = "", P1081 = ""
↓
quantity, reference

↓

Only gets properties from claims that have at least one reference.
Q55 = "", P2855 = "", P518 = ""
↓
entity label

↓

Gets a single qualifier value (for each matching claim).
Q55 = "", P2855 = "", P518 = ""
↓
entity label

↓

Gets multiple qualifier values (for each matching claim).
Q55 = "", P2855 = "", P518 = ""
↓
quantity, entity label

↓

Gets multiple property values along with multiple qualifier values.
Q55 = "", P2855 = "", P518 = ""
↓
quantity, entity label

↓

Returns the output with custom separators.
Q55 = "", P35 = "", P580 = "", P582 = ""
↓
entity label, time

↓

Gets two different qualifier values for each claim.
Q55 = "", P35 = "", P580 = "", P582 = ""
↓
entity label, time

↓

Returns the output with a custom separator.
Q55 = "", P35 = "", P580 = "", P582 = ""
↓
entity label, time

↓

Returns the output in a custom format instead of with a custom separator.
Q55 = "", P35 = "", P580 = "", P582 = ""
↓
entity label, time

↓

To add text only when a certain value is not present, like adding the word since if there is no end time, wrap it in between two optional blocks containing HTML comment tags and the relevant parameter (this also prevents the text from being added to the page source).
Q55 = "", P35 = "", Q29574 = "", P580 = "", P582 = ""
↓
entity label, time

↓

Gets a property with qualifiers from claims for which the property matches a given Q-identifier, with one of the qualifier values in its raw form.
Q55 = "", P38 = "", P518 = ""
↓
entity label

↓

Gets claims that are currently valid.
Q55 = "", P38 = ", P518 = ""
↓
entity label

↓

Gets claims with linked property values.
Q55 = "", P38 = ", P518 = ""
↓
entity label

↓

Gets claims with linked qualifier values.
Q55 = "", P38 = ", P518 = ""
↓
entity label

↓

Gets claims with linked property and qualifier values, with short property values wherever available.
Q55 = "", P38 = ", Q4917 = "", P518 = ""
↓
entity label

↓

Gets qualifiers from claims for which the (raw) property value matches a given Q-identifier.
Q55 = "", P38 = ", P518 = "", Q27561 = ""
↓
entity label

↓

Gets properties from claims for which a (raw) qualifier value matches a given Q-identifier.
Q55 = "", P38 = "
↓
entity label

↓

Gets claims that were valid in the past.
Q55 = "", P38 = "
↓
entity label

↓

Gets raw property values.
Q55 = "", P38 = "
↓
entity label

↓

Gets raw property values that are linked to Wikidata.
Q55 = "", P1549 = ""
↓
monolingual text

↓

Gets a monolingual text value in the current wiki's language.
Q55 = "", P1549 = "", P407 = "", Q36846 = ""
↓
monolingual text

↓

Gets a monolingual text value in any available language.
Q55 = "", P2884 = ""
↓
quantity

↓

Gets a quantity value with its associated unit of measurement.
Q55 = "", P2884 = ""
↓
quantity

↓

Gets a quantity value with a linked unit of measurement.
Q55 = "", P2884 = ""
↓
quantity

↓

Gets a raw quantity value.
Q55 = "", P2884 = ""
↓
quantity

↓

Gets only the unit of measurement.
Q55 = "", P2884 = ""
↓
quantity

↓

Gets the raw unit of measurement.
Q55 = "", P625 = ""
↓
globe coordinate

↓

Gets a globe coordinate value.
Q55 = "", P625 = ""
↓
globe coordinate

↓

Gets a linked globe coordinate value.
Q55 = "", P625 = ""
↓
globe coordinate

↓

Gets a raw globe coordinate value.
Q55 = "", P625 = ""
↓
globe coordinate

↓

A property alias can be used instead of the P-identifier.
Q55 = "", P41 = ""
↓
commons media

↓

Gets a media file name and links to it on Commons.
Q55 = "", P41 = ""
↓
commons media

↓

A Commons media file can be included on the page as-is by omitting the linked and raw flags, but by using the raw flag it can be freely formatted.
Q915684 = "", P2534 = ""
↓
math

↓

Gets a mathematical expression.
Q6256 = "", P3896 = ""
↓
geographic shape

↓

Gets a geographic shape data file name and links to it on Commons.
Q4917 = ""
↓
entity label

↓

Gets an item's label.
Q4917 = ""
↓
entity label

↓

Gets an item's short and linked label.
P38 = "
↓
entity label

↓

Gets a property's label.
P38 = "
↓
entity label

↓

Gets a property's label that is linked to Wikidata.
Q776 = ""
↓
entity label

↓

Gets an item's label.
Q776 = ""
↓
entity label

↓

Gets an item's linked label.

↓
entity label

↓

If the  is transcluded on the  page (which is linked to Q776), then the Q776 can be omitted.

↓
entity label

↓

If just the label command with the raw flag is given, then the Q-identifier of the item connected to the current page is returned.
Q776 = ""
↓
page title

↓

Gets the title of the page on the current wiki that is linked to the given item.
Q776 = ""
↓
page title

↓

Gets the linked title of the page on the current wiki that is linked to the given item.

↓
page title

↓

If the  is transcluded on the  page (which is linked to Q776), then the Q776 can be omitted.
Q55 = ""
↓
entity description

↓

Gets an item's description.

↓
entity description

↓

If the  is transcluded on the  page (which is linked to Q55), then the Q55 can be omitted.
Q55 = ""
↓
entity alias

↓

Gets one of an item's aliases.
Q55 = ""
↓
entity alias

↓

Gets all of an item's aliases.
Q55 = ""
↓
entity alias

↓

Gets a linked alias from an item.

↓
entity alias

↓

If the  is transcluded on the  page (which is linked to Q55), then the Q55 can be omitted.
Q2 = ""
↓
page badge

↓

Gets the badges for the page on the current wiki that is linked to the given item.
Q2 = ""
↓
page badge

↓

Gets the raw badges for the page on the current wiki that is linked to the given item.

↓
page badge

↓

If the  is transcluded on the  page (which is linked to Q2), then the Q2 can be omitted.

**Example references**

**See also**
Pageid to title, to get a page title using its local page id, rather than Wikidata