Redigerer
Modul:WikidataIB/dok
(avsnitt)
Hopp til navigering
Hopp til søk
Advarsel:
Du er ikke innlogget. IP-adressen din vil bli vist offentlig om du redigerer. Hvis du
logger inn
eller
oppretter en konto
vil redigeringene dine tilskrives brukernavnet ditt, og du vil få flere andre fordeler.
Antispamsjekk.
Ikke
fyll inn dette feltet!
== Utility functions == === Function getLink === getLink has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= If there is a sitelink to an article on the local Wiki, it returns a link to the article with the Wikidata label as the displayed text. If there is no sitelink, it returns the label as plain text. If there is no label in the local language, it displays the qid instead. : Wikidata: {{q|Q29016906}} and {{q|Q3621491}} * <code><nowiki>{{#invoke:WikidataIB |getLink |Q29016906}}</nowiki></code> → {{#invoke:WikidataIB |getLink |Q29016906}} * <code><nowiki>{{#invoke:WikidataIB |getLink |Q3621491}}</nowiki></code> → {{#invoke:WikidataIB |getLink |Q3621491}} === Function getLabel === getLabel has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= It returns the Wikidata label for the local language as plain text. If there is no label in the local language, it displays the qid instead. Note that this is the label given to the Wikidata entry in the same language as the current Wiki, if the label exists. : Wikidata: {{q|Q29016906}} and {{q|Q3621491}} * <code><nowiki>{{#invoke:WikidataIB |getLabel |Q29016906}}</nowiki></code> → {{#invoke:WikidataIB |getLabel |Q29016906}} * <code><nowiki>{{#invoke:WikidataIB |getLabel |Q3621491}}</nowiki></code> → {{#invoke:WikidataIB |getLabel |Q3621491}} === Function getAT === getAT has the qid of a Wikidata entity passed as the first unnamed parameter or as |qid= If there is a sitelink to an article on the local Wiki, it returns the sitelink as plain text, i.e. the article title. If there is no sitelink, it returns nothing. Note that this is the title of the article in the current Wikipedia, if the interlanguage link exists in the Wikidata entry. : Wikidata: {{q|Q29016906}} and {{q|Q3621491}} * <code><nowiki>{{#invoke:WikidataIB |getAT |Q29016906}}</nowiki></code> → {{#invoke:WikidataIB |getAT |Q29016906}} * <code><nowiki>{{#invoke:WikidataIB |getAT |Q3621491}}</nowiki></code> → {{#invoke:WikidataIB |getAT |Q3621491}} === Function getDescription === getDescription has the qid of a Wikidata entity passed as |qid= (it defaults to the associated qid of the current article if omitted). It has a local parameter passed as the first unnamed parameter. Any local parameter passed (other than "Wikidata" or "none") becomes the return value. It returns the article description for the Wikidata entity in plain text if the local parameter is "Wikidata". Nothing is returned if the description doesn't exist or "none" is passed as the local parameter. : Wikidata: {{q|Q29016906}} and {{q|Q3621491}} * <code><nowiki>{{#invoke:WikidataIB |getDescription |qid=Q29016906 |wikidata}}</nowiki></code> → {{#invoke:WikidataIB |getDescription |qid=Q29016906 |wikidata}} * <code><nowiki>{{#invoke:WikidataIB |getDescription |qid=Q29016906 |A painting}}</nowiki></code> → {{#invoke:WikidataIB |getDescription |qid=Q29016906 |A painting}} * <code><nowiki>{{#invoke:WikidataIB |getDescription |qid=Q29016906 |none}}</nowiki></code> → {{#invoke:WikidataIB |getDescription |qid=Q29016906 |none}} * <code><nowiki>{{#invoke:WikidataIB |getDescription |qid=Q3621491 |wikidata}}</nowiki></code> → {{#invoke:WikidataIB |getDescription |qid=Q3621491 |wikidata}} * <code><nowiki>{{#invoke:WikidataIB |getDescription |qid=Q3621491 |A profession}}</nowiki></code> → {{#invoke:WikidataIB |getDescription |qid=Q3621491 |A profession}} * <code><nowiki>{{#invoke:WikidataIB |getDescription |qid=Q3621491 |none}}</nowiki></code> → {{#invoke:WikidataIB |getDescription |qid=Q3621491 |none}} === Function formatDate === formatDate accepts a datetime of the usual format from mw.wikibase.entity:formatPropertyValues, like "1 August 30 BCE" as parameter 1 and formats it according to the df (date format) and bc parameters. * <code><nowiki>{{#invoke:WikidataIB |formatDate | 1 August 30 BCE |bc=BCE |df=dmy}}</nowiki></code> → {{#invoke:WikidataIB |formatDate | 1 August 30 BCE |bc=BCE |df=dmy}} * <code><nowiki>{{#invoke:WikidataIB |formatDate | 1 August 30 BCE |bc=BC |df=mdy}}</nowiki></code> → {{#invoke:WikidataIB |formatDate | 1 August 30 BCE |bc=BC |df=mdy}} * df = "dmy" / "mdy" / "y" - default is "dmy" * bc = "BC" / "BCE" - default is "BCE" === Function checkBlacklist === checkBlacklist allows a test to check whether a named field is allowed. It returns true if the field is not blacklisted (i.e. allowed) It returns false if the field is blacklisted (i.e. disallowed) Example: * <code><nowiki>{{#if:{{#invoke:WikidataIB |checkBlacklist |name=nationality |suppressfields=residence; nationality; citizenship}} | not blacklisted | blacklisted}}</nowiki></code> → {{#if:{{#invoke:WikidataIB |checkBlacklist |name=nationality |suppressfields=residence; nationality; citizenship}} | not blacklisted | blacklisted}} * <code><nowiki>{{#if:{{#invoke:WikidataIB |checkBlacklist |name=birth_place |suppressfields=residence; nationality; citizenship}} | not blacklisted | blacklisted}}</nowiki></code> → {{#if:{{#invoke:WikidataIB |checkBlacklist |name=birth_place |suppressfields=residence; nationality; citizenship}} | not blacklisted | blacklisted}} === Function emptyor === emptyor returns nil if its first unnamed argument is just punctuation, whitespace or html tags otherwise it returns the argument unchanged (including leading/trailing space). If the argument could contain "=", then it must be called explicitly: * <code><nowiki>| 1 = whatever-the-argument-is</nowiki></code> In that case, leading and trailing spaces are trimmed. It finds use in infoboxes where it can replace tests like: * <code><nowiki>{{#if: {{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}} | <span class="xxx">{{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}}</span> | }}</nowiki></code> with a form that uses just a single call to Wikidata: * <code><nowiki>{{#invoke |WikidataIB |emptyor |1= <span class="xxx">{{#invoke:WikidataIB |getvalue |P99 |fwd=ALL}}</span> }}</nowiki></code> === Function labelorid === labelorid is a public function to expose the output of labelOrId(). The Q-number (entity ID) is passed as |qid= or as an unnamed parameter. It returns the Wikidata label for that entity or the qid if no label exists. === Function getLang === getLang returns the MediaWiki language code of the current content. If optional parameter |style=full, it returns the language name. === Function getQid === * getQid works with the current page and its associated Wikidata entry. * It returns qid, if supplied as the first unnamed parameter or as {{para|qid}}; * failing that, the Wikidata entity ID of the "category's main topic (P301)", if it exists; * failing that, the Wikidata entity ID asociated with the curent page, if it exists; * otherwise, nothing === Function examine === examine provides a dump of the entire property given in the first unnamed parameter (or in {{para|pid}} as a named alias) from the item given by the parameter 'qid', or from the item corresponding to the current page if qid is not supplied. Both parameters may be unnamed and given in any order. It works in a similar manner to the [[Module:Wikidata|Dump]] function, but only loads a single claim, rather than the whole Wikidata entry. * Example: <code><nowiki>{{#invoke:WikidataIB |examine |qid=Q1396889 |P50}}</nowiki></code> There is a [[Template:Examine]] which acts as a wrapper for the call. * Example: <code><nowiki>{{examine |Q4048254 |P31}}</nowiki></code> → {{examine |Q4048254 |P31}} === Function url2 === url2 takes a parameter url= that is a proper url and formats it for use in an infobox. Examples Noting that <code><nowiki>{{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no}}</nowiki></code> → {{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no}}: * <code><nowiki>{{#invoke:WikidataIB |url2 |url= http://www.example.com/ }}</nowiki></code> → {{#invoke:WikidataIB |url2 |url= http://www.example.com/ }} * <code><nowiki>{{#invoke:WikidataIB |url2 |url= http://www.example.com/path/ }}</nowiki></code> → {{#invoke:WikidataIB |url2 |url= http://www.example.com/path/ }} * <code><nowiki>{{#invoke:WikidataIB |url2 |url= {{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no}} }}</nowiki></code> → {{#invoke:WikidataIB |url2 |url= {{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no}} }} Comparison with output of {{tl|URL}}: * <code><nowiki>{{URL | http://www.example.com/ }}</nowiki></code> → {{URL | http://www.example.com/ }} * <code><nowiki>{{URL | http://www.example.com/path/ }}</nowiki></code> → {{URL | http://www.example.com/path/ }} * <code><nowiki>{{URL | {{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no|noicon=yes}} }}</nowiki></code>→ {{URL | {{wdib |P856 |qid=Q23317 |fwd=ALL |osd=no|noicon=yes}} }} <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | <!-- Categories below this line, please; interwikis at Wikidata --> [[Category:Wikidata modules]] }}</includeonly>
Redigeringsforklaring:
Merk at alle bidrag til Wikisida.no anses som frigitt under Creative Commons Navngivelse-IkkeKommersiell-DelPåSammeVilkår (se
Wikisida.no:Opphavsrett
for detaljer). Om du ikke vil at ditt materiale skal kunne redigeres og distribueres fritt må du ikke lagre det her.
Du lover oss også at du har skrevet teksten selv, eller kopiert den fra en kilde i offentlig eie eller en annen fri ressurs.
Ikke lagre opphavsrettsbeskyttet materiale uten tillatelse!
Avbryt
Redigeringshjelp
(åpnes i et nytt vindu)
Navigasjonsmeny
Personlige verktøy
Ikke logget inn
Brukerdiskusjon
Bidrag
Opprett konto
Logg inn
Navnerom
Modul
Diskusjon
norsk bokmål
Visninger
Les
Rediger kilde
Vis historikk
Mer
Søk
Navigasjon
Forside
Siste endringer
Tilfeldig side
Hjelp til MediaWiki
Spesialsider
Verktøy
Lenker hit
Relaterte endringer
Sideinformasjon
På andre prosjekter