Difference between revisions of "Template:Formatter link/doc"

From blackwiki
Jump to navigation Jump to search
imported>Uzume
imported>Struthious Bandersnatch
 
Line 5: Line 5:
 
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.
 
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, which uses the code as display.
+
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.
 
Supplying the code as a parameter to this template allows one call to be made to Wikidata to fetch the code.
Line 20: Line 20:
 
== See also ==
 
== See also ==
 
* {{tl|Wikidata ID}} and {{tl|Wikidata ID line}}
 
* {{tl|Wikidata ID}} and {{tl|Wikidata ID line}}
 +
* {{tl|format link}}, a similarly-named but completely unrelated template
  
 
<includeonly>{{sandbox other||
 
<includeonly>{{sandbox other||

Latest revision as of 13:14, 7 November 2020

Wikidata contains many examples of "External identifiers" such as Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P267) – see Anatomical Therapeutic Chemical Classification System.

These codes are used with Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (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 |code= and uses a formatter url as |url= to construct a link to the external resource; an optional |label= parameter sets the text of the link, defaulting to the value of |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 Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (Q26979), Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P267):

  • {{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}} }}Template:Wdib Template:Wdib

The formatter url to use for Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P267) can be found from:

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:

  • {{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}} }}

See also