4

I want to insert tables in infoboxes. For example, I have a proteinbox I've developed using the infobox template (http://health-and-medicine.wikia.com/wiki/Template:Proteinbox), and its FASTA field is too large to fit comfortably in the proteinbox. Hence I would like it to be a collapsible table inside the box.

This is what I tried:

{{infobox
 | Row 1 = 
  {| class = "mw-collapsible mw-collapsed wikitable"
  |-
  | <!-- Some table content -->
  |}
}}
leo
  • 8,106
  • 7
  • 48
  • 80
Josh Pinto
  • 1,453
  • 4
  • 20
  • 37

2 Answers2

3

Your problem is, that you are putting the nested table inside a template. The pipe characters (|) in the table syntax then collides with the pipe usage in templates.

The most commonly used hack to get around this is to create a template called Template:!, simply containing only the pipe character, and then use that when you need to put tables, parser functions or other stuff using pipe characters, inside templates. Your table would then look like this (with every | replaced by {{!}}):

{{{!}}
{{!}}-
{{!}} A1
{{!}} B1
{{!}}-
{{!}} A2
{{!}} B2
{{!}}}

...the equivalent of

{|
|-
| A1
| B1
|-
| A2
| B2
|}

Furthermore, you have to assure that the table starts at a new line, as blank lines are stripped from template parameters. The easiest way is to add an empty <nowiki /> tag. The code in your question would then look like this:

{{infobox
 | Row 1 = <nowiki />
  {{{!}} class = "mw-collapsible mw-collapsed wikitable"
  {{!}}-
  {{!}} <!-- Some table content -->
  {{!}}}
}}

In recent versions of MediaWiki, the {{!}} syntax is added to the software, but on Wikia, as of 2017, this needs to be added to a template.

leo
  • 8,106
  • 7
  • 48
  • 80
  • I implemented these changes and, well suffice it to say it didn't workout a hitch, see http://health-and-medicine.wikia.com/wiki/Cytokines#Interleukins. Any ideas of how I could possibly make it so that the proteinboxes still fit inside article pages? Plus the content isn't exactly collapsed either. If for whatever reason you can't see what I see here it is http://i.imgur.com/wrF6qDF.png. – Josh Pinto Nov 04 '14 at 10:45
  • If there are no table heders, the first row will be treated as the header, when creating an expandable table. In your case, you have only one row, so that will always be visible. Try adding a table header! See also http://community.wikia.com/wiki/Help:Collapsing, or post a new question about this if you get stuck! – leo Nov 04 '14 at 11:02
  • I added a header, it didn't work either. The header was entered using a new row starting with either {{!}} or ! and it didn't work. – Josh Pinto Nov 04 '14 at 11:10
  • Yes it does. (I purged your page for you.) Please post a new question if you are having troubles with expandable tables. It makes it easier for other users with similar problems to find help, if try to keep to one question for each issue. – leo Nov 04 '14 at 11:17
0

Just as further information to Leo's answer above (i unfortunately can't comment yet), please note that {{!}} is a magic word in MediaWiki now and needs template no more.

Please refer to https://www.mediawiki.org/wiki/Template:! and https://gerrit.wikimedia.org/r/#/c/136234/ for details on this modification in MW.

lucamauri
  • 142
  • 3
  • 13