Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  



1.1  Prefix and suffix  



1.1.1  Infobox field with microformat  





1.1.2  Table  









2 See also  





3 See also  














Template:If then show






Afrikaans
ि
العربية
Asturianu
Авар
تۆرکجه
Basa Bali

Banjar
 / Bân-lâm-gú
Bosanski
Буряад
Català
Cebuano
ChiShona
Corsu
Cymraeg
Dagbanli
الدارجة
Eesti
Ελληνικά
Esperanto
Euskara
فارسی
Gaeilge
Gaelg
Galego


Hausa
Hrvatski
Ilokano
Bahasa Indonesia

Kernowek
Ikirundi
Kotava
Kurdî
Latina
Lietuvių
ि

Malti


 / Mìng-dĕ̤ng-nḡ

Na Vosa Vakaviti


Occitan
Oʻzbekcha / ўзбекча

Português
Română
Русиньскый
Sakizaya

Simple English
Slovenščina
کوردی
Српски / srpski
ி
Taqbaylit

Türkçe
Українська
اردو
Vèneto
Tiếng Vit
Wayuunaiki


Betawi
 
 

Edit links
 









Template
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikimedia Commons
MediaWiki
Wikidata
Wikiversity
Wiktionary
 
















Appearance
   

 





Permanently protected template

From Wikipedia, the free encyclopedia
 


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 {{#invoke: }} of a Lua module that may return a value or nothing. Because it uses the {{#invoke: }} 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

spouse (P26) for Richard Burton (Q151973)
{{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q151973|fwd=ALL|osd=no}}|unmarried}}Elizabeth Taylor, Sybil Christopher, Suzy Miller, Elizabeth Taylor, Sally Burton Edit this on Wikidata
spouse (P26) for Franz Kafka (Q905)
{{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q905|fwd=ALL|osd=no}}|unmarried}} → 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:

{{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>}}
If there is a local parameter supplied in the article (e.g. |birth_place=London), the code will return <span class="birthplace">London</span>.
If there is no local parameter it will attempt to fetch a value for place of birth (P19) from Wikidata.
If that has a value, such as "New York", the code will return <span class="birthplace">New York</span>.
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.

spouse (P26) for Richard Burton (Q151973)
{| 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>}}
|}
Label Value
spouseElizabeth Taylor, Sybil Christopher, Suzy Miller, Elizabeth Taylor, Sally Burton Edit this on Wikidata
spouse (P26) for Franz Kafka (Q905)
{| 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>}}
|}
Label Value

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 {{#invoke: 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 |code= and uses a formatter url as |url= to construct a link to the external resource, which uses the code as display.
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.

See also


Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:If_then_show&oldid=1078129334"

Category: 
If-then-else templates
Hidden category: 
Wikipedia template-protected templates
 



This page was last edited on 20 March 2022, at 01:04 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki