Difference between revisions of "Template:Infobox book/Wikidata/Sandbox"

From blackwiki
Jump to navigation Jump to search
imported>RexxS
(add qid just for demo purposes)
imported>RexxS
(getSourcedValue is deprecated)
 
(2 intermediate revisions by 2 users not shown)
Line 25: Line 25:
 
| imagestyle = {{#if:{{{image|}}}||display:none}}
 
| imagestyle = {{#if:{{{image|}}}||display:none}}
 
| image = {{#if:{{{image|}}} <!--
 
| image = {{#if:{{{image|}}} <!--
   then:-->|   {{#ifeq:{{str left|{{{image|}}}|1}}|[ |{{main other|[[Category:Pages using deprecated image syntax]]}} }}<!--
+
   then:-->| {{#invoke:InfoboxImage|InfoboxImage |image={{{image|}}} |size={{{image_size|}}} |sizedefault=frameless |upright=1 |alt={{{alt|}}} |border={{{border|}}} |suppressplaceholder=yes}}<!--
            -->{{#invoke:InfoboxImage|InfoboxImage |image={{{image|}}} |size={{{image_size|}}} |sizedefault=frameless |upright=1 |alt={{{alt|}}} |border={{{border|}}} |suppressplaceholder=yes}}<!--
 
 
   else:-->| {{#ifeq:{{yesno|{{lc:{{{exclude_cover|no}}}}}}}|yes | |{{main other|[[Category:Books with missing cover]]}} }}
 
   else:-->| {{#ifeq:{{yesno|{{lc:{{{exclude_cover|no}}}}}}}|yes | |{{main other|[[Category:Books with missing cover]]}} }}
 
           }}
 
           }}
Line 152: Line 151:
  
 
| label38  = Website
 
| label38  = Website
| data38    = {{#invoke:WikidataIB |getSourcedValue |P856 |name=pages |fetchwikidata={{{fetchwikidata|}}} |suppressfields={{{suppressfields|}}} |{{{website|{{{homepage|{{{URL|}}}}}}}}} |qid={{{qid|}}} }}
+
| data38    = {{#invoke:WikidataIB |getValue |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%;
Line 166: Line 165:
 
         -->{{#if:{{{english_release_date|}}} |<!--[[Category:Infobox book using deprecated parameters|d {{PAGENAME}}]]-->}}<!--
 
         -->{{#if:{{{english_release_date|}}} |<!--[[Category:Infobox book using deprecated parameters|d {{PAGENAME}}]]-->}}<!--
 
         -->{{#if:{{{isbn2|}}} |[[Category:Infobox book using deprecated parameters|i {{PAGENAME}}]]}}<!--
 
         -->{{#if:{{{isbn2|}}} |[[Category:Infobox book using deprecated parameters|i {{PAGENAME}}]]}}<!--
     -->}}{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using infobox book with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Infobox book]] with unknown parameter "_VALUE_"|ignoreblank=y| alt | audio_read_by | author | authors | award | awards | border | caption | congress | country | cover_artist | dewey | editor | editors | english_pub_date | english_release_date | exclude_cover | external_host | external_url | fetchwikidata | first | followed_by | followed_by_quotation_marks | genre | genres | homepage | illustrator | illustrators | image | image_caption | image_size | infoboxwidth | isbn | ISBN  | isbn2 | isbn_note | ISBN_note | italic title | language | last | location | media_type | name | native_external_host | native_external_url | native_wikisource | note | notes | oclc | orig_lang_code | pages | preceded_by | preceded_by_quotation_marks | pub_date | published | publisher | publisher2 | release_date | release_number | series | set_in | subject | subjects | suppressfields | title_orig | title_working | translator | translators | URL | website | width | wikisource }}<noinclude>
+
     -->}}{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using infobox book with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Infobox book]] with unknown parameter "_VALUE_"|ignoreblank=y| alt | audio_read_by | author | authors | award | awards | border | caption | congress | country | cover_artist | dewey | editor | editors | english_pub_date | english_release_date | exclude_cover | external_host | external_url | fetchwikidata | first | followed_by | followed_by_quotation_marks | genre | genres | homepage | illustrator | illustrators | image | image_caption | image_size | infoboxwidth | isbn | ISBN  | isbn2 | isbn_note | ISBN_note | italic title | language | last | location | media_type | name | native_external_host | native_external_url | native_wikisource | note | notes | oclc | orig_lang_code | pages | preceded_by | preceded_by_quotation_marks | pub_date | published | publisher | publisher2 | qid | release_date | release_number | series | set_in | subject | subjects | suppressfields | title_orig | title_working | translator | translators | URL | website | width | wikisource }}<noinclude>
 
{{Documentation}}
 
{{Documentation}}
 
</noinclude>
 
</noinclude>

Latest revision as of 20:44, 9 April 2018

Template documentation[view] [edit] [history] [purge]

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

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.