Difference between revisions of "Template:Infobox book/Wikidata/Sandbox"
imported>RexxS (allow paras suppressfields fetchwikidata) |
imported>RexxS (add qid just for demo purposes) |
||
| Line 36: | Line 36: | ||
| label2 = Author{{#if:{{{authors|}}}|s}} | | label2 = Author{{#if:{{{authors|}}}|s}} | ||
| − | | data2 = {{#invoke:WikidataIB |getValue |P50 |name=author |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{authors|{{{author|}}}}}} }} | + | | data2 = {{#invoke:WikidataIB |getValue |P50 |name=author |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{authors|{{{author|}}}}}} |qid={{{qid|}}} }} |
| label3 = Audio read by | | label3 = Audio read by | ||
| Line 72: | Line 72: | ||
| label15 = Genre{{#if:{{{genres|}}}|s}} | | label15 = Genre{{#if:{{{genres|}}}|s}} | ||
| − | | data15 = {{#invoke:WikidataIB |getValue |P136 |name=genre |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{genres|{{{genre|}}}}}} }} | + | | data15 = {{#invoke:WikidataIB |getValue |P136 |name=genre |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{genres|{{{genre|}}}}}} |qid={{{qid|}}} }} |
| label16 = Set in | | label16 = Set in | ||
| Line 84: | Line 84: | ||
| label19 = {{longitem|Publication date}} | | label19 = {{longitem|Publication date}} | ||
| − | | data19 = {{#invoke:WikidataIB |getValue |P577 |name=pub_date |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{pub_date|{{{release_date|}}}}}} }} | + | | data19 = {{#invoke:WikidataIB |getValue |P577 |name=pub_date |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{pub_date|{{{release_date|}}}}}} |qid={{{qid|}}} }} |
| label20 = {{longitem|Published in English}} | | label20 = {{longitem|Published in English}} | ||
| Line 93: | Line 93: | ||
| label22 = Pages | | label22 = Pages | ||
| − | | data22 = {{#invoke:WikidataIB |getValue |P1104 |name=pages |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{pages|}}} }} | + | | data22 = {{#invoke:WikidataIB |getValue |P1104 |name=pages |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{pages|}}} |qid={{{qid|}}} }} |
| label23 = Award{{#if:{{{awards|}}}|s}} | | label23 = Award{{#if:{{{awards|}}}|s}} | ||
| Line 110: | Line 110: | ||
| label32 = {{longitem|[[Dewey Decimal Classification|Dewey Decimal]]}} | | label32 = {{longitem|[[Dewey Decimal Classification|Dewey Decimal]]}} | ||
| − | | data32 = {{#invoke:WikidataIB |getValue |P1036 |name=dewey |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{dewey|}}} }} | + | | data32 = {{#invoke:WikidataIB |getValue |P1036 |name=dewey |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{dewey|}}} |qid={{{qid|}}} }} |
| label33 = [[Library of Congress Classification|{{abbr|LC Class|Library of Congress Classification}}]] | | label33 = [[Library of Congress Classification|{{abbr|LC Class|Library of Congress Classification}}]] | ||
| − | | data33 = {{#invoke:WikidataIB |getValue |P1149 |name=congress |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{congress|}}} }} | + | | data33 = {{#invoke:WikidataIB |getValue |P1149 |name=congress |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{congress|}}} |qid={{{qid|}}} }} |
| label34 = Preceded by | | label34 = Preceded by | ||
| Line 152: | Line 152: | ||
| label38 = Website | | label38 = Website | ||
| − | | data38 = {{ | + | | data38 = {{#invoke:WikidataIB |getSourcedValue |P856 |name=pages |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{website|{{{homepage|{{{URL|}}}}}}}}} |qid={{{qid|}}} }} |
| − | |||
| − | |||
| − | |||
| belowstyle = border-top:#aaa 1px solid;font-size:90%; | | belowstyle = border-top:#aaa 1px solid;font-size:90%; | ||
Revision as of 14:50, 20 June 2016
| Website | Script error: The function "getSourcedValue" does not exist. |
|---|
Testing sandbox for a wikidata-aware Infobox book.
This uses a 'blacklist' of fields that will never be displayed, by using the parameter |suppressfields, e.g.:
| suppressfields = dewey; congress
It uses a 'whitelist' of fields that will be fetched from Wikidata, by using the parameter |fetchwikidata (unless the field is suppressed or a local value is supplied), e.g.:
| fetchwikidata = author; genre; pub_date; pages; dewey; congress
Any separators can be used, except | and {} as you might expect.
The snag will be if a field name is included inside another field name like "date" is inside "pub_date". Try to avoid naming parameters like that.
As a shorthand the whitelist of fields to be fetched from Wikidata can be given the value ALL, for all available fields.
| fetchwikidata = ALL
Parameters supported so far are: Template:Ubl
Contents
Usage
No Wikidata
{{Infobox book/Wikidata/Sandbox
| suppressfields =
| fetchwikidata =
| name = Animal Farm
| title_orig = Animal Farm: A Fairy Story
| image = Animal Farm - 1st edition.jpg
| image_size = 200px
| caption = First edition cover
| author = [[George Orwell]]
| country = United Kingdom
| language = English
| genre = Political satire
}}
Works as a non-aware infobox: only locally supplied parameters are displayed.
{{Infobox book/Wikidata/Sandbox
| name = Animal Farm
| title_orig = Animal Farm: A Fairy Story
| image = Animal Farm - 1st edition.jpg
| image_size = 200px
| caption = First edition cover
| author = [[George Orwell]]
| country = United Kingdom
| language = English
| genre = Political satire
}}
The blacklist and whitelist can be omitted if unused
All Wikidata
{{Infobox book/Wikidata/Sandbox
| suppressfields =
| fetchwikidata = author; genre; pub_date; pages; dewey; congress
}}
Fetches all of its values from Wikidata.
{{Infobox book/Wikidata/Sandbox
| fetchwikidata = ALL
}}
As shorthand, the |fetchwikidata= can be set to ALL to fetch all available fields.
Any of them can be suppressed by |suppressfields=, or overridden by supplying a local value.
Never display genre
{{Infobox book/Wikidata/Sandbox
| suppressfields = genre
| fetchwikidata = author; genre; pub_date; pages; dewey; congress
}}
The genre field will always be suppressed, even if a local value is supplied.
{{Infobox book/Wikidata/Sandbox
| suppressfields = genre
| fetchwikidata = author; genre; pub_date; pages; dewey; congress
| genre = Political satire
}}
Local override
{{Infobox book/Wikidata/Sandbox
| fetchwikidata = author; genre; pub_date; pages; dewey; congress
| genre = Political satire
}}
The genre field is set to display "Political satire", no matter what is stored in Wikidata.
{{Infobox book/Wikidata/Sandbox
| fetchwikidata = ALL
| genre = Novel
}}
The genre field is set to display "Novel", no matter what is stored in Wikidata.
Don't fetch genre
{{Infobox book/Wikidata/Sandbox
| suppressfields =
| fetchwikidata = author; pub_date; pages; dewey; congress
}}
The genre field will not be fetched from Wikidata.
| The above documentation is transcluded from Template:Infobox book/Wikidata/Sandbox/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |