Search code examples
mediawikimediawiki-templates

Mediawiki: Displaying a List does not work with infobox template


I created a new template and want to display a list inside my newly coded infobox. To get this working I was told to change the code like in this German tutorial.

This is how my template Infobox Music currently looks like:

|- 
{{#if: {{{Sänger<includeonly>|</includeonly>}}} |
 {{#ifeq: {{Str left|{{{Sänger}}} }} | *
  |{{!}} style="vertical-align:top;" {{!}}
'''Sänger/in'''
{{!}}
{{{Sänger}}}
  |{{!}} '''Sänger/in'''
{{!}} {{{Sänger}}}
 }}
}}

In order to build a new list I edited the source code in a seperate Wiki entry like this:

{{Infobox_Music
|Sänger = 
* Lady Gaga
* Michael Jackson
}}

Unfortunately, when using both of these settings my list gets displayed with the first item having an * at the beginning just as usual. Here is how it looks in HTML:

<tr>
<td> <b>Sänger/in</b>
</td>
<td> * Lady Gaga
<ul><li>Michael Jackson</li></ul>
</td></tr>

Did I miss something? What does the line {{#ifeq: {{Str left|{{{Sänger}}} }} mean?

UPDATE: Here is a snippet of my previous Infobox Music template:

{{Infobox Music
    |- 
    {{#if: {{{Sänger|}}} | {{!}} '''Sänger/in''' {{!!}} {{{Sänger}}} }}
}}

Solution

  • {{Str left|{{{Sänger}}} }} is the first character of the Sänger parameter (see {{Str left}}). {{#ifeq: {{Str left|{{{Sänger}}} }} | * | ... is some kind of horrible hack to use a different layout when the parameter is a list; not trying to replicate that will help you preserve your sanity.

    * will only be interpreted as a list when preceded by a newline. You can prevent stripping of the leading whitespace from the template parameter by doing something like

    |Sänger = <!---->
    * Lady Gaga
    

    or you can make sure that in the template {{{Sänger}}} is preceded by a newline.