mediawikimediawiki-templates

How I create an optional row in an InfoBox in MediaWiki?


I want to create a row that doesn't appear if it's not specified. I have the following around the row in question:

{{#if:{{{author|}}}|
|-
| '''Author'''
| {{{author}}}
}}

But in practice, adding 'author' doesn't make anything appear, am I writing this incorrectly?


EDIT: thanks for the help, updated it to be this:

{{!}}{{#if:{{{author|}}}|<nowiki />
{{!}}-
{{!}} '''Author'''
{{!}} {{{author|Value}}}
}}

Solution

  • here is an example on how to add conditional rows to a wiki table, maybe this also works for the infoBox 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 {{
    #if: {{{artikelthumbnail|}}}|<nowiki />
    {{!}}-
    {{!}} colspan="2" style="border: none" {{!}} {{{artikelthumbnail}}}
    }}
    |-
    |-
    | colspan="2" style= "text-align: center; border: none; font-size: 15px;"|'''Basisdaten''' {{
    #if: {{{artikeltitel|}}}|<nowiki />
    {{!}}-
    {{!}} style="border: none" {{!}} '''Artikeltitel:'''
    {{!}} style="width:200px; border: none;" {{!}} {{{artikeltitel}}} }}{{
    #if: {{{veröffentlichungsdatum|}}}|<nowiki />
    {{!}}-
    {{!}} style="border: none" {{!}} '''Veröffentlichung:'''
    {{!}} style="width:200px; border: none;" {{!}} {{{veröffentlichungsdatum}}}
    }}
    |}
    

    taken from Mediawiki display table row only if value is present