Moodul:Wikidata2/doc
Ilme
See on üksuse Moodul:Wikidata2 dokumentatsiooni lehekülg.
This module gives format to the data extracted from Wikidata
Simple functions
claim
: It gives the value or values of a qualifier, in the format we ask for. By default, it uses the item (Qnnnn) of the article it is transcluded.
Other functions:
getParentValues
: it gives the values and labels of a propiety, recursively, up to the limit we say.getTAValue
: it gives the value of TA98 (first edition of Terminologia Anatomica, 1998) in the property P1323. There're not extra parameters for this function, but it gives a list with the correct external link format.ViewSomething
: we can see anything inside the data, including labels, descriptions, references or interwiki links.years_old
: it gives the age of a person. If the person is dead it gives the difference between P569 and P570. If there's not a P570 property, it gives the difference between P569 and the current date. According to the precision of the data, it could give two different numbers. If one of the dates is given in century format, there won't be an answer.- The syntax is these:
{{#invoke:Wikidata |years_old|formatting=''pattern''|item=}}
.item
andformatting
are not mandatory. And example would beformatting = ($1 years)
- The syntax is these:
- Full syntax
{{#invoke:Wikidata|claim|property= |qualifier= |value= |list= |tablesort= |formatting= |separator= |conjunction= |item= |showerrors= |default= }}
- If we want it in a table format:
{{#invoke:Wikidata|claim|property= |qualifier= |qualifier2= |...|qualifier9= |tablesort= |rowformat= |colformat0= | colformat1 = |...|rowsubformat1= |...|rowsubformat9= |formatting=table |separator= |conjunction= |item= |showerrors= |default= }}
- Functions for the claim function
property=
(mandatory) The property we want to get, "P" followed by the number. For the full list of properties in Wikidata, see List of properties. You can write it with a little p, but is not recommended. You can even use the label of the property, for example property=country would be the same as property=P17.qualifier=
(optional) The proprety of the qualifier, a "P" followed by a number. It would give the link to the qualifier item. You can write it with a little p, but is not recommended.value=
(optional) It inserts a preferent value to override the Wikidata item. You can use it inside a template, with a {{{parameter|}}} value.list=
(optional). By default list=true, and it gives all the claims of the quliafier (see separator and conjunction).list=false
It gives a unique value. It would give the highest ranked one from preferent/normal/deprecated or the oldest one if all are of the same rank.list=firstrank
It gives a list of all the items of the highest level. Is the same as list=true if all the elements are of the same level.tablesort=0
(optional) it orders the list from bottom to top. By default the order would be according to the level and age of the claims.
formatting=
(optional) The format we want to give to the claim:- Format of the element (entity):
formatting=raw
It gives the Qnnnn value of the element.formatting=label
It gives the label of the element.formatting=sitelink
It gives the link of the Wikipedia link for that element.formatting=internallink
Internal link if possible. This can be a sitelink or a label. If there's not a link but there's a label, it will give a red link to that label. If there's not a label, it will give the English label by default.formatting=pattern
A pattern we give, using $1 as the element to change.
- We can insert templates and parser functions, but we need to use special templates:{{((}}Name of the template{{!}}Parameter{{!}}Parameter{{))}}
- The default formatting will be a link.
- Text format (strings):
formatting=weblink
External link format [http://example.com example.com]formatting=pattern
A pattern we give, using $1 as the element to change. Example:formatting=[http://whc.unesco.org/en/list/$1 $1]
. We can use it in the cases where Wikidata creates external links, and the correct pattern will be in the Talk of the Propiety.
- Number format (quantity):
formatting=unit
The number and the unitformatting=unitcode
The number and the abbr. of the unit. It needs ca:Module:Wikidata/Units.
- Language format (monolingualtext):
formatting=language
It gives the language of the parameter we want to get, for the items that are formatted as monolingual text, i.e. P1448.formatting=text
a special version of the format monolingual text, it only gets the text. If we don't use formatting we would get the text and the language code as in<span lang="en">United...</span>
.formatting=eu
or another language. It gives a unique value, in this case the monolingual text value for the Basque language. This can be used with P2521.
- Format for coordinates (globecoordinate) --> but for better uses see ca:Template:Cal coor:
formatting=latitude
It gives the latitude in decimal format.formatting=longitude
It gives the longitude in decimal formatformatting=dimension
It gives the dimension of the coordinates, in meters, so we can use with the dim parameter of the maps.formatting=globe
(by default) it gives the globe parameter for the coordinate template. If we use an external object, you could use ca:Mòdul:Mapa cos celeste/dades
- Time format (time):
formatting= format #time
it works with any #time format. For example formatting=d-m-Y (07-11-2024), formatting=[[j xg]] (7 novembri), formatting=Y (2024). By default uses "j F Y" (7 november 2024).
- Table format for properties and qualifiers
formatting=table
It gives a list of properties, in a table format, with its qualifiers. It can have up to 9 qualifiers, and every group will be inserted in a row. It uses the separator and conjunction separators as parameters. You can use a lot of different options:qualifier2 ... qualifier9=
if you need more than onequalifier
rowformat=
Formats every row of properties and qualifiers. We use $0 to mark the property, and from $1 to $9 to mark the qualifiers. By default it givesrowformat=$0 ($1, ... $9)
. We can use list items as * and #, and also templates with the syntax {{((}}, {{!}} and {{))}}.rowsubformat1 ... rowsubformat9=
you can define the subformat of every item from $1 to $9. It would be very useful if any qualifier is not present in the item. For example, if you have "rowformat=$0 $1" and "rowsubformat1= or $1" would give "$0 or $1" if both are present and "$0" if there is not "$1".colformat0 ... colformat9=
It gives format to every column, using 0 for the property and 1-9 for the qualifiers. We can use any parameter defined informatting
. So we can make extra operations with every column.tablesort=
With values from 0 to 9, it orders the table according to that property or qualifier. By default the table is ordered according to the level or age of the Wikidata items in $0.sorting=-1
it gives just the opposite sorting for the ordering. By default is from bottom to top.
- Format of the element (entity):
separator=
(optional) for using both in lists and tables. By default, is a comma (, ). In tables, by default, is a line break: <br />.conjunction=
(optional) it inserts a conjunction in the last elements of a list. By default is and . In tables is a line break: <br />.case=
(optional) not in the Catalan Module. You can see it in the Basque module. You can give declension to words, items...item=
(optional) it works with an article that is not the current. We have to insert it using Qnnnn. Use it moderately, please, as the amount of resources are finite.itemgender=
(optional) It gives the gender of the item, using P21.showerrors=
(optional) It shows the error messages.default=
(optional) The message to give if there's an error. It doesn't show if showerrors is on.
- Parameters of getParentValues function
item=
(optional) it allows inserting an item (Qnnnnn). This random approach to Wikidata is not recommended, as is quite resource-consuming.property=
(optional) The property we want to search for parents. By default is P131.label=
(optional) The label of the property. By default is P31.valuetext=
(optional) Value of the link of the property. By default is formatting=internallink.upto=
(optional) Where we want to stop the tree. It will give properties till is reached.- upto=label: a label that determines the stop signal. For example "upto=state".
- upto=number: the number of items we want to get. By default is 10, but normally we wouldn't find so much.
labelshow=
(optional) A filter for the kind of labels we want to show, with a slash to divide them. For example: "labelshow=municipality/region"sorting=
(optional) The order of the list. It does only have one possible value, "sorting=-1", in order to show just the opposite order.rowformat=
(optional) the way in which we show the $0 label and $1 values. By default, "rowformat=$0 = $1", but we can use others,, for example rowformat=<tr><td>'''$0'''</td><td>$1</td>separator=
(optional) The separator of every value couple. By default is <br />. We don't need conjunctions in this function.
Note: Labels can be changed so they fit better in the infoboxes. For example, "Municipality of Brazil" can be changed to "Municipality". We can do this using ca:Module:Wikidata/labels, making every change needed in our language.
- Examples
- Simple use:
- {{#invoke:Wikidata | claim |property=P20}} in the article Jean-François Champollion
- Property P20 showing the element.
- Without link:
- {{#invoke:Wikidata | claim | property=P20 | formatting=label}}
- Default value
- {{#invoke:Wikidata | claim | property=P20 | value={{{death place|}}} }} if we define {{{death place|}}} in the infobox, it will appear, if not, Paris should be rendered.
- Date format
- {{#invoke:Wikidata | claim | property=P569}} gives the birth date in the correct format
- Values given with a pattern:
- {{#invoke:Wikidata | claim | property=P214 | formatting=[http://viaf.org/viaf/$1 $1]}}
- Unique value:
- {{#invoke:Wikidata | claim | property=P18 | list=false | formatting=[[File:$1|thumb|upright=.5|Example image]]}}
- It will give only the first defined image.
- Formatting of external link
- {{#invoke:Wikidata | claim | property=P856 | formatting=weblink}} in the Berlin article
- Value list
- List with format
- Mall:P {{#invoke:Wikidata | claim | property=P527 | separator=<br /> | conjunction=<br />}} in the article Basque Country
- Coordinates:
- {{#invoke:Wikidata | claim | property=P625 | formatting=latitude}}
- {{#invoke:Wikidata | claim | property=P625 | formatting=longitude}}