Editing
Template:If then show/doc
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Documentation subpage}} <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> {{High-use}} This template tests whether the first unnamed parameter is not an empty string and returns it if it is not empty. Otherwise it returns the second unnamed parameter. This is useful when the first parameter is a <nowiki>{{#invoke: }}</nowiki> of a Lua module that may return a value or nothing. Because it uses the <nowiki>{{#invoke: }}</nowiki> just once, it simplifies the coding of infoboxes, for example. The optional third and fourth unnamed parameters provide a prefix and a suffix for the first parameter when returned. This enables the designer to construct more complex templates that still only use one invoke of a Lua module. == Usage == ; {{q|P26}} for {{q|Q151973}} : <syntaxhighlight lang="wikitext" inline>{{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q151973|fwd=ALL|osd=no}}|unmarried}}</syntaxhighlight> β {{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q151973|fwd=ALL|osd=no}}|unmarried}} ; {{q|P26}} for {{q|Q905}} : <syntaxhighlight lang="wikitext" inline>{{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q905|fwd=ALL|osd=no}}|unmarried}}</syntaxhighlight> β {{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q905|fwd=ALL|osd=no}}|unmarried}} === Prefix and suffix === ==== Infobox field with microformat ==== A value in an infobox can be designed to be wrapped in a microformat if the wikidata call is not empty: : <syntaxhighlight lang="wikitext" inline>{{if then show | {{#invoke:WikidataIB | getValue | rank=best |P19 |name=birth_place |qid={{{qid|}}} |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |noicon={{{noicon|}}} | {{{birth_place|}}} }} || <span class="birthplace"> | </span>}}</syntaxhighlight> : If there is a local parameter supplied in the article (e.g. {{para|birth_place|London}}), the code will return <code><nowiki><span class="birthplace">London</span></nowiki></code>. : If there is no local parameter it will attempt to fetch a value for {{q|P19}} from Wikidata. : If that has a value, such as "New York", the code will return <code><nowiki><span class="birthplace">New York</span></nowiki></code>. : If there is no value returned from Wikidata, the code returns nothing. ==== Table ==== A table can be designed to display a row only when a particular property of the article exists on Wikidata. ; {{q|P26}} for {{q|Q151973}} : <syntaxhighlight lang="wikitext"> {| class="wikitable" |- ! scope="col" style="width:15em;" | Label ! scope="col" style="width:36em;" | Value {{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q151973|fwd=ALL|osd=no}}||<tr><th>{{#invoke:WikidataIB|getLabel|P26|qid=Q151973}}</th><td>|</td></tr>}} |} </syntaxhighlight> : β {| class="wikitable" |- ! scope="col" style="width:15em;" | Label ! scope="col" style="width:36em;" | Value {{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q151973|fwd=ALL|osd=no}}||<tr><th>{{#invoke:WikidataIB|getLabel|P26|qid=Q151973}}</th><td>|</td></tr>}} |} ; {{q|P26}} for {{q|Q905}} : <syntaxhighlight lang="wikitext"> {| class="wikitable" |- ! scope="col" style="width:15em;" | Label ! scope="col" style="width:36em;" | Value {{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q905|fwd=ALL|osd=no}}||<tr><th>{{#invoke:WikidataIB|getLabel|P26|qid=Q905}}</th><td>|</td></tr>}} |} </syntaxhighlight> : β {| class="wikitable" |- ! scope="col" style="width:15em;" | Label ! scope="col" style="width:36em;" | Value {{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q905|fwd=ALL|osd=no}}||<tr><th>{{#invoke:WikidataIB|getLabel|P26|qid=Q905}}</th><td>|</td></tr>}} |} == See also == ; [[Template:Ifnoteq then show]] : tests whether the first unnamed parameter is equal to the second unnamed parameter and returns the third unnamed parameter if it does. Otherwise it returns the first unnamed parameter. This is useful when the first parameter is a <code><nowiki>{{#invoke:</nowiki></code> of a Lua module that returns a value for which a specific exception is required. ; [[Template:If then wikilink]] : tests whether the first unnamed parameter is not an empty string and if it isn't, it returns the parameter formatted as piped wiki-link using an optional namespace prefix. ; [[Template:Formatter link]] : 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. ; [[Template:Empty or|Template:Emptyor]] : tests a piece of text to ascertain whether it's effectively empty or contains some text. If the unnamed parameter consists only of html tags, punctuation (e.g. Wiki-markup) and whitespace, then Emptyor returns nothing; otherwise it returns the parameter unchanged. Wrapper for p.emptyor function. == Further readings == * {{mfl|params|value_of}} <includeonly>{{sandbox other|| <!-- Categories below this line, please; interwikis at Wikidata --> [[Category:If-then-else templates]] }}</includeonly>
Summary:
Please note that all contributions to Eurovision Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Eurovision Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Pages included on this page:
Template:Documentation subpage
(
edit
)
Template:High-use
(
edit
)
Template:If then show
(
edit
)
Template:Mbox
(
edit
)
Template:Mfl
(
edit
)
Template:Module function link
(
edit
)
Template:Para
(
edit
)
Template:Q
(
edit
)
Template:Replace
(
edit
)
Template:Strong
(
edit
)
Template:Terminate sentence
(
edit
)
Template:Wikidata entity link
(
edit
)
Module:Arguments
(
edit
)
Module:High-use
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Separated entries
(
edit
)
Module:String
(
edit
)
Module:TableTools
(
edit
)
Module:Text
(
edit
)
Module:Text/data
(
edit
)
Module:Transclusion count
(
edit
)
Module:Transclusion count/data/I
(
edit
)
Module:Wd
(
edit
)
Module:Wd/i18n
(
edit
)
Module:WikidataIB
(
edit
)
Module:WikidataIB/nolinks
(
edit
)
Module:WikidataIB/titleformats
(
edit
)
Module:Yesno
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Template
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Tools
What links here
Related changes
Page information