Difference between revisions of "Demo:IfStatement"
Line 26: | Line 26: | ||
==Simple Case== | ==Simple Case== | ||
Knowing that <code>{{#If: condition| YES | NO}}</code> can decide whether to show something or not, | Knowing that <code>{{#If: condition| YES | NO}}</code> can decide whether to show something or not, this feature can be applied in the following way. | ||
<nowiki>{{#If: 1 |Something to show | Nothing to show|}}</nowiki> | <nowiki>{{#If: 1 |Something to show | Nothing to show|}}</nowiki> | ||
Line 38: | Line 38: | ||
{{#If: |Something to show | Nothing to show|}} | {{#If: |Something to show | Nothing to show|}} | ||
==Template Coding== | |||
Knowing this feature, we can judge whether certain portion of a template would show or not. |
Revision as of 07:31, 2 July 2021
This page tries to use a set of nested If Statement to demonstrate the logic of Template inclusion:
For example: If there is a book citation, it can be included using the PageName
instruction.
{{:Cite:book:Working with MediaWiki}}
Koren, Yaron (2020). Working with MediaWiki (2nd ed.). local page: WikiWorks Press. ISBN 978-1540761149.
This entry has many attributes, some of the attributes may have empty(null) value. The goal is to demonstrate that we can use the {{#If condition| YES | NO}}
structure to determine how to show certain content or not.
For example: The data content in Koren, Yaron (2020). Working with MediaWiki (2nd ed.). local page: WikiWorks Press. ISBN 978-1540761149.
can be seen here:
{{cite book
|last=Koren
|first=Yaron
|author-link=Yaron Koren
|title=Working with MediaWiki
|edition=2nd
|url=https://workingwithmediawiki.com
|location=
|publisher=WikiWorks Press
|page= <!-- or pages= -->
|isbn=978-1540761149
|date=2020
}}
Simple Case
Knowing that YES
can decide whether to show something or not, this feature can be applied in the following way.
{{#If: 1 |Something to show | Nothing to show|}}
The following is the actual result:
Something to show
{{#If: |Something to show | Nothing to show|}}
The following is the actual result:
Nothing to show
Template Coding
Knowing this feature, we can judge whether certain portion of a template would show or not.