Admin Forum:Creating Custom Table

Forums: Admin Central Index → Technical Help → Creating Custom Table Wikia's forums are a place for the community to help other members. To contact staff directly or to report bugs, please use Special:Contact.

Hi! I want to create a table that can have multiple rows but not show every row if the content isn't added. I took a look at the infobox code, but I can't figure out what is going on or how to add more column! Can someone explain what is going on for me? Thank you! ~ （天気） 06:50, November 30, 2011 (UTC)

{| class="infobox" style="font-size:89%; width:300px; background-color:#FFF;" 
 * style="width:30%;" |
 * style="width:30%;" |
 * style="width:70%;" |

{{#if: {{{Row 2 title|}}}| {{!}}- {{!}} {{{Row 2 title}}} {{!}} {{{Row 2 info|No information}}} {{#if: {{{Row 3 title|}}}| {{!}}- {{!}} {{{Row 3 title}}} {{!}} {{{Row 3 info|No information}}} {{#if: {{{Row 4 title|}}}| {{!}}- {{!}}

. ..

{{{Row 10 info|No information}}} {{#if: {{{Row 11 title|}}}| {{!}}- {{!}} colspan="2" style="text-align:center; background:#AAAAAA;" {{!}} Too many parameters


 * Do you mean you want to create a template that have optionally visible rows?
 * If so... there are things called Parser Functions in MediaWiki that accomplish that. The "#if:" things do that in this case

{{#if: test | if true do this | if false do this }}
 * So {{#if: {{{parametername|}}} | do stuff to create the row }} would do what you want. Take note that when building tables inside that if statement, you need to replace "}" with {{t|)}} and "{" with {{t|(}} and "|" with {{t|!}} . You probably don't have {{t|)}} and {{t|(}} and need to copy those two templates onto your wiki as well. The only time "|" should appear in the if statement is the one or two times in the example. The only time } and { should appear are to start and end the if statement. The only exception to that is if you place a template/parameter call inside the if statement. Like

{{#if: {{{param1|}}} | {{{param1}}} is a {{t|infobox}} | param1 is missing }}
 * this shows if checking for param1, and then if it exists, printing it. It also calls the template t and passes that template the parameter1=infobox. and if it does not exist, it prints "param1 is missing"
 * So if you want to do a table row

{{#if: {{{paramX|}}} | ! row title {{!}} column2 stuff {{!}} column3 stuff }}
 * will print out something like:


 * for that row, when paramX is set.
 * ForestMonthZero 09:15, November 30, 2011 (UTC)

Thank you!! Now it's clear what it is doing to me. :). ~ （天気） 17:48, November 30, 2011 (UTC)
 * Additional useful parser functions can be found on the MediaWiki help page.{{User:TK-999/sig2}} 17:52, November 30, 2011 (UTC)