Forum:Help with Infoboxes

ShoutWiki — express yourself and be heard!
Jump to navigation Jump to search
Forums: Index > Community help

So, I'm trying to set up an infobox template to create other infoboxes from and I need some help with some things.

This is how my infobox looks like right now.

First of all, I need to get that second header to become an actual header, like the first one. I've tried a lot of things but that's the closest I could get. But I also need to learn how to make it work with the {{#if: thing (I tried it before and couldn't get it), because some of the infoboxes I'll be creating will need it and some won't. I should probably make the image and its caption optional too.

Also, how can I get the titles to be aligned with the first row of their respective fields? I'd find it easier to read the infobox like that.

Here's my code:

<includeonly>{| align="right" style="background:#b0d5d3; border: 2px solid #2d848a; width:280px;"
|-
| align="center" style="background:#2d848a; color:#FFFFFF;"| '''<big>{{{name|{{PAGENAME}}}}}</big>'''
|-
| 
{| align="center"
| align="center" style="background: none;" | [[File:{{{image}}}|150px]]
|-
| align="center" | {{{caption}}}
|}
|-
| align="center" style="background:#2d848a; color:#FFFFFF;"| '''{{{subject1}}}'''
|-
|
{| align="center" 
{{#if:{{{field1|}}}|
! align="left" width="80px" {{!}} {{{title1}}}:
{{!}} {{{field1}}} }}
|-
{{#if:{{{field2|}}}|
! align="left" width="80px" {{!}} {{{title2}}}:
{{!}} {{{field2}}} }}
|-
{{#if:{{{field3|}}}|
! align="left" width="80px" {{!}} {{{title3}}}:
{{!}} {{{field3}}} }}
|-
{{#if:{{{field4|}}}|
! align="left" width="80px"{{!}} {{{title4}}}:
{{!}} {{{field4}}} }}
|-
{{#if:{{{field5|}}}|
! align="left" width="80px" {{!}} {{{title5}}}:
{{!}} {{{field5}}} }}
|-
{{#if:{{{field6|}}}|
! align="left" width="80px" {{!}} {{{title6}}}:
{{!}} {{{field6}}} }}
|-
{{#if:{{{field7|}}}|
! align="left" width="80px" {{!}} {{{title7}}}:
{{!}} {{{field7}}} }}
|-
{{#if:{{{field8|}}}|
! align="left" width="80px" {{!}} {{{title8}}}:
{{!}} {{{field8}}} }}
|-
{{#if:{{{field9|}}}|
! align="left" width="80px" {{!}} {{{title9}}}:
{{!}} {{{field9}}} }}
|-
{{#if:{{{field10|}}}|
! align="left" width="80px" {{!}} {{{title10}}}:
{{!}} {{{field10}}} }}
|-
|
{| align="center"
|}
| align="center" style="background:#2d848a; color:#FFFFFF;"| '''{{{subject2}}}'''
|-
{{#if:{{{field11|}}}|
! align="left" width="80px" {{!}} {{{title11}}}:
{{!}} {{{field11}}} }}
|-
{{#if:{{{field12|}}}|
! align="left" width="80px" {{!}} {{{title12}}}:
{{!}} {{{field12}}} }}
|-
{{#if:{{{field13|}}}|
! align="left" width="80px" {{!}} {{{title13}}}:
{{!}} {{{field13}}} }}
|-
{{#if:{{{field14|}}}|
! align="left" width="80px" {{!}} {{{title14}}}:
{{!}} {{{field14}}} }}
|-
{{#if:{{{field15|}}}|
! align="left" width="80px" {{!}} {{{title15}}}:
{{!}} {{{field15}}} }}
|-
{{#if:{{{field16|}}}|
! align="left" width="80px" {{!}} {{{title16}}}:
{{!}} {{{field16}}} }}
|-
{{#if:{{{field17|}}}|
! align="left" width="80px" {{!}} {{{title17}}}:
{{!}} {{{field17}}} }}
|-
{{#if:{{{field18|}}}|
! align="left" width="80px" {{!}} {{{title18}}}:
{{!}} {{{field18}}} }}
|-
{{#if:{{{field19|}}}|
! align="left" width="80px" {{!}} {{{title19}}}:
{{!}} {{{field19}}} }}
|-
{{#if:{{{field20|}}}|
! align="left" width="80px" {{!}} {{{title20}}}:
{{!}} {{{field20}}} }}
|-
|}
|}</includeonly>

--Shenzai (talk) 05:22, 9 March 2014 (UTC)

Hi Shenzai,
Here's some fixed up code for you:
<includeonly>{| align="right" style="background:#b0d5d3; border: 2px solid #2d848a; width:280px;"
|-
| align="center" style="background:#2d848a; color:#FFFFFF;"| '''<big>{{{name|{{PAGENAME}}}}}</big>'''
|-
| 
{{#if:{{{image|}}} | 
{{{!}} align="center"
{{!}} align="center" style="background: none;" {{!}} [[File:{{{image}}}|150px]]
{{!}}-
{{#if:{{{caption|}}} | 
{{!}} align="center" {{!}} {{{caption}}}
}}
{{!}}} }}
|-
| align="center" style="background:#2d848a; color:#FFFFFF;"| '''{{{subject1}}}'''
|-
|
{| align="center" 
{{#if:{{{field1|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title1}}}:
{{!}} {{{field1}}} }}
|-
{{#if:{{{field2|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title2}}}:
{{!}} {{{field2}}} }}
|-
{{#if:{{{field3|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title3}}}:
{{!}} {{{field3}}} }}
|-
{{#if:{{{field4|}}}|
! valign="top" align="left" width="80px"{{!}} {{{title4}}}:
{{!}} {{{field4}}} }}
|-
{{#if:{{{field5|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title5}}}:
{{!}} {{{field5}}} }}
|-
{{#if:{{{field6|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title6}}}:
{{!}} {{{field6}}} }}
|-
{{#if:{{{field7|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title7}}}:
{{!}} {{{field7}}} }}
|-
{{#if:{{{field8|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title8}}}:
{{!}} {{{field8}}} }}
|-
{{#if:{{{field9|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title9}}}:
{{!}} {{{field9}}} }}
|-
{{#if:{{{field10|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title10}}}:
{{!}} {{{field10}}} }}
|-
{{#if:{{{subject2|}}}|
{{!}} align="center" colspan="2" style="background:#2d848a; color:#FFFFFF;"{{!}} '''{{{subject2}}}'''
}}
|-
{{#if:{{{field11|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title11}}}:
{{!}} {{{field11}}} }}
|-
{{#if:{{{field12|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title12}}}:
{{!}} {{{field12}}} }}
|-
{{#if:{{{field13|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title13}}}:
{{!}} {{{field13}}} }}
|-
{{#if:{{{field14|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title14}}}:
{{!}} {{{field14}}} }}
|-
{{#if:{{{field15|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title15}}}:
{{!}} {{{field15}}} }}
|-
{{#if:{{{field16|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title16}}}:
{{!}} {{{field16}}} }}
|-
{{#if:{{{field17|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title17}}}:
{{!}} {{{field17}}} }}
|-
{{#if:{{{field18|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title18}}}:
{{!}} {{{field18}}} }}
|-
{{#if:{{{field19|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title19}}}:
{{!}} {{{field19}}} }}
|-
{{#if:{{{field20|}}}|
! valign="top" align="left" width="80px" {{!}} {{{title20}}}:
{{!}} {{{field20}}} }}
|-
|}
|}</includeonly>
I fixed the second header by removing some seemingly randomly placed code (which created an empty table) and using colspan="2" (it wouldn't work with the random table there as it was taking up the first column). As for why you were struggling with ifs, I don't know but I've applied them to this, the image and the caption. Also, I fixed the aligning of the titles using valign="top".
Hope this helps,
Best regards,
--Cook879 ShoutWiki Staff talk 17:13, 10 March 2014 (UTC)