Forum:What am I doing wrong with infoboxes?

ShoutWiki — express yourself and be heard!
Jump to navigation Jump to search

Forums: Index Community help

I know less that nothing about coding, but I want just a simple infobox for my wiki. The problem is that it never turns out right? I'll put a copy of the code, I made some random edits to see if it would fix it but I don't know if it made it better or worse.

{| style="border: 1px solid #aaa; border-spacing: 0; float: right; margin: 0 0 .5em 1em; width: 300px;"
| style="background-color: #ffffff; text-align: center;" |
 <p style="font-size: larger;">'''{{{name|{{PAGENAME}}}}}'''</p>
 <div style="background-color: #ffffff; margin: 0 25px;">[[File:{{{image}}}|250px|link=]]</div>
 <p>{{{caption}}}</p>
|-
| style="text-align: center;" | <u>'''Basic information'''</u>
{| style="margin: 0 25px; text-align: center;"
{{#if:{{{other names|}}}|
! style="text-align: center;" {{!}} Other Names:
{{!}} {{{other names}}} }}
{{#if:{{{gender|}}}|
{{!}}-
! style="text-align: center;" {{!}} Gender:
{{!}} {{{gender}}} }}
{{#if:{{{sex|}}}|
{{!}}-
! style="text-align: center;" {{!}} Sex:
{{!}} {{{sex}}} }}
{{#if:{{{age|}}}|
{{!}}-
! style="text-align: center;" {{!}} Age:
{{!}} {{{age}}} }}
{{#if:{{{birthday|}}}|
{{!}}-
! style="text-align: center;" {{!}} Birthday:
{{!}} {{{birthday}}} }}
{{#if:{{{sexual orientation|}}}|
{{!}}-
! style="text-align: center;" {{!}} Sexual Orientation:
{{!}} {{{sexual orientation}}} }}
|-
| style="text-align: center;" | <u>'''Occupational Information'''</u>
{| style="margin: 0 25px; text-align: center;"
{{#if:{{{job|}}}|
! style="text-align: center;" {{!}} Job:
{{!}} {{{job}}} }}
{{#if:{{{class|}}}|
{{!}}-
! style="text-align: center;" {{!}} Class:
{{!}} {{{class}}} }}
|-
| style="text-align: center;" | <u>'''Relationships'''</u>
{| style="margin: 0 25px; text-align: center;"
{{#if:{{{family|}}}|
! style="text-align: center;" {{!}} Family:
{{!}} {{{family}}} }}
{{#if:{{{romance|}}}|
{{!}}-
! style="text-align: center;" {{!}} Romantic Relationships:
{{!}} {{{romance}}} }}
{{#if:{{{close friendships|}}}|
{{!}}-
! style="text-align: center;" {{!}} Close Friendships:
{{!}} {{{close friendships}}} }}
{{#if:{{{tense|}}}|
{{!}}-
! style="text-align: center;" {{!}} Tense Relationships:
{{!}} {{{tense}}} }}
|}
|}

—The preceding unsigned comment was added by EchoOfStarlight (talkcontribs) 17:18, 2 November 2019‎ (UTC). Please sign your posts with --~~~~!


Hello. So I'm not an expert with wikicode, either, but I do have some coding experience. I tried taking a look at another infobox for comparison. Here's a snippet of coding from it:

{{#if: {{{Level|}}} | {{!}} width=80 {{!}} <div>Level</div> {{!!}} {{{Level}}} }}
|-
{{#if: {{{Difficulty|}}} | {{!}} <div>[[Difficulty]]</div> {{!!}} {{{Difficulty}}} }}
|-

The first thing I noticed is that, on this other infobox template, there's a "|-" between every field, while yours seems to be missing a lot of those. (There's also some spacing differences - I don't think those are too likely to be a part of the problem, but I guess it's worth trying to put more spaces between the different parts of code.) I don't know if this is a style thing or a functionality thing, but it could be a factor.

I'm also noticing that the other infobox doesn't seem to have any "!"s without any brackets around them - that could also be a factor.

Taking another look, the other infobox also starts with this piece of coding:

{| class="infoboxtable"
|-
! colspan="2" class="infoboxname" |

I think there's a pretty good chance that the biggest issue is that you're missing the 'class="infoboxtable"' and/or 'class="infoboxname"' parts. That's just my guess as a coder who's fairly new to wikicode, though. XD;

So how about you try those out and let me know if you're still having problems? =) If so, could you tell me exactly what kind of problems you're still having? Maybe include an image?

I hope that helps. ^_^ Scia (talk) 00:11, 5 November 2019 (UTC)

Most infoboxes are just wiki tables. I'd suggest simply starting out learning to make tables in wiki markup. There's no advantage to using CSS classes that may not exist on the given wiki. --Saftzie (talk) 05:43, 5 November 2019 (UTC)