2,492 bytes added
, 3 years ago
{{Documentation subpage}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
Wikidata contains many examples of "External identifiers" such as {{q|P267}} – see [[Anatomical Therapeutic Chemical Classification System]].
These codes are used with {{q|P1630}} such as http://www.whocc.no/atc_ddd_index/?code=$1 where the $1 is to be substituted by the ATC code.
This template takes an external identifier code as {{para|code}} and uses a formatter url as {{para|url}} to construct a link to the external resource; an optional {{para|label}} parameter sets the text of the link, defaulting to the value of {{para|code}} otherwise.
Supplying the code as a parameter to this template allows one call to be made to Wikidata to fetch the code.
== Example ==
For {{q|Q26979}}, {{q|P267}}:
* <code><nowiki>{{Formatter link |url=http://www.whocc.no/atc_ddd_index/?code=$1 |code={{wdib |P267 |qid=Q26979 |fwd=ALL |osd=n |noicon=y |maxvals=1}} }}</nowiki></code> → {{Formatter link |url=http://www.whocc.no/atc_ddd_index/?code=$1 |code={{wdib |P267 |qid=Q26979 |fwd=ALL |osd=n |noicon=y |maxvals=1}} }}
The formatter url to use for {{q|P267}} can be found from:
* <code><nowiki>{{wdib |P1630 |qid=P267 |fwd=ALL |osd=n}}</nowiki></code> → {{wdib |P1630 |qid=P267 |fwd=ALL |osd=n}}
In infoboxes, it will generally be hard-coded because it is specific to the infobox field. Otherwise the following can be used if Wikidata changes of the formatter url should be tracked:
*<code><nowiki>{{Formatter link |url={{wdib |P1630 |qid=P267 |fwd=ALL |osd=n |noicon=y}} |code={{wdib |P267 |qid=Q26979 |fwd=ALL |osd=n |noicon=y |maxvals=1}} }}</nowiki></code>
== See also ==
* {{tl|Wikidata ID}} and {{tl|Wikidata ID line}}
* {{tl|format link}}, a similarly-named but completely unrelated template
==Template data==
<templatedata>
{
"params": {
"code": {
"description": "the unique ID value of the target page",
"required": true
},
"url": {
"description": "the Wikidata “formatter URL (P1630)”",
"required": true
},
"label": {
"description": "the text of the link (defaults to the value of “code”)"
}
},
"description": "Combines a Wikidata “formatter URL (P1630)” with an id code to produce a URL",
"format": "inline"
}
</templatedata>
<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Wikidata templates]]
}}</includeonly>