Community Central

Admin Forum:Creating Custom Table

18,824pages on
this wiki
Add New Page
Add New Page Talk0

This Forum has been archived

Forums: Admin Central Index Technical Help Creating Custom Table
Central's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.
Note: This topic has been unedited for 1326 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.

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%;" |
'''{{{Row 1 title|No Title}}}'''
| style="width:70%;" |
{{{Row 1 info|No information}}}
{{#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 {{)}} and "{" with {{(}} and "|" with {{!}} . You probably don't have {{)}} and {{(}} 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:
row title column2 stuff column3 stuff
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 pageTK999 17:52, November 30, 2011 (UTC)

Also on Fandom

Random Wiki