I am the admin of a wiki an currently working on an infobox template. It is made up of a simple table with some variables. Nothing special.
The problem is, that I would like to have an if statment so that only the table rows ar visible where the variable has a value. I have looked in to existing templates on other wikis but can't figure out how to adapt the code.
The following is the code for my template:
{|class="wikitable" style="float:right; margin-left: 10px; border: #94bf88 thin solid;"
|+
! colspan="2" style="background-color: #d9ffda; font-weight: bold; font-size: 20px; color: black; border: none;" |Artikelinformationen
|-
| colspan="2" style="border: none" |{{{artikelthumbnail}}}
|-
|-
| colspan="2" style= "text-align: center; border: none; font-size: 15px;"|'''Basisdaten'''
|-
|style="border: none"|'''Artikeltitel:'''
| style="width:200px; border: none;" |{{{artikeltitel}}}
|-
|style="border: none"|'''Veröffentlichung:'''
| style="width:200px; border: none;" |{{{veröffentlichungsdatum}}}
|-
|style="border: none"|'''Herausgeber:'''
| style="width:200px; border: none;" |{{{herausgeber}}}
|-
|style="border: none"|'''Art:'''
| style="width:200px; border: none;" |{{{herausgeberart}}}
|-
|style="border: none"|'''Mediengruppe:'''
| style="width:200px; border: none;" |{{{mediengruppe}}}
|-
|style="border: none"|'''Autoren:'''
| style="width:200px; border: none;" |{{{autoren}}}
|-
| colspan="2" style= " text-align: center; border: none; font-size: 15px;"|'''Details'''
|-
|style="border: none"|'''Absätze:'''
| style="width:200px; border: none;" |{{{absätze}}}
|-
|style="border: none"|'''Sätze:'''
| style="width:200px; border: none;" |{{{sätze}}}
|-
|style="border: none"|'''Wörter:'''
| style="width:200px; border: none;" |{{{wörter}}}
|-
|style="border: none"|'''Zeichen:'''
| style="width:200px; border: none;" |{{{zeichen}}}
|-
| colspan="2" style= " text-align: center; border: none; font-size: 15px;"|'''Links'''
|-
|style="border: none"|'''Herausgeber:'''
| style="width:200px; border: none;" |{{{link_heruasgeber}}}
|-
|style="border: none"|'''Artikel in PDF:'''
| style="width:200px; border: none;" |{{{link_pdf}}}
|-
|style="border: none"|'''Artikel im Archiv:'''
| style="width:200px; border: none;" |{{{link_archiv}}}
|}
So for expample: if the variable {{{artikeltitel}}} is empty, both
|style="border: none"|'''Artikeltitel:'''
| style="width:200px; border: none;" |{{{artikeltitel}}}
|-
are not visable.
Only if {{{artikeltitel}}} is given a value, the line shows up when importing the Template into an article.
Thanks in advance.
You need to put the if statement on the preceding row.
Try this
isolated example: