Forum:Template infobox - Section Hiding, Parameter Defaults & Entry Based Infobox Changes

Hello. I want to create a universal infobox for my wikia. Can anyone explain how to have an inbox hide information based on a lack of content or appear as a defualt statement such as N/A. I also want to know if there is a method that changes the appearance and content of the box based upon the user's entry for a certain column. In addition an explanation for how to create an all around background color for a single column would also be nice. Outlaw630 17:25, April 18, 2012 (UTC)


 * Please split up your questions into separate sections or posts. -- Fandyllic (talk &middot; contr) 18 Apr 2012 1:53 PM Pacific


 * You're basically looking for a primer on infoboxes. I'd suggest you take a look around, because there are just about as many approaches to infoboxes as there are people coding them. I can give you a brief tutorial here, bearing in mind that other people have different theories.


 * To make a variable not display if there is no value for the variable use a simple  statement like:
 * This statement means that if there is no value to, nothing will be output to the infobox. Most forms of "hideable" infobox variables use an #if statement of some kind, or maybe a #switch.  Note that | is a simple template found on most wikis that means the same thing as a pipe (|).  For technical reasons, however, you can't always put a pipe directly in a statement, so | lets you "say it without saying it".  If that makes no sense to you, you might be able to get some more information from this wiki's ! template.
 * This statement means that if there is no value to, nothing will be output to the infobox. Most forms of "hideable" infobox variables use an #if statement of some kind, or maybe a #switch.  Note that | is a simple template found on most wikis that means the same thing as a pipe (|).  For technical reasons, however, you can't always put a pipe directly in a statement, so | lets you "say it without saying it".  If that makes no sense to you, you might be able to get some more information from this wiki's ! template.


 * If you want a variable to have a default value just add the default value after the pipe. One I use all the time is to make the name of the infobox default to the PAGENAME.  It looks like this:
 * This means that it looks for something at the variable . If if doesn't find that  is defined, then it prints the PAGENAME.  You can do this with any variable.  However, I'd caution against having a lot of N/As all over the place.  If you don't have a value for a variable, it takes up less vertical space in the infobox if you just don't print anything.
 * This means that it looks for something at the variable . If if doesn't find that  is defined, then it prints the PAGENAME.  You can do this with any variable.  However, I'd caution against having a lot of N/As all over the place.  If you don't have a value for a variable, it takes up less vertical space in the infobox if you just don't print anything.


 * "I also want to know if there is a method that changes the appearance and content of the box based upon the user's entry for a certain column." Not quite sure what you mean here. You literally could mean any one of an endless number of effects.  You're gonna need to be more specific.


 * "an explanation for how to create an all around background color for a single column would also be nice". I'm sure it would be.  It's not that easy though.  Infoboxes are tables which are made up of individual cells.  They aren't actually made up of columns.  I'm not particularly aware of a single command that will change the appearance of (what seems to be) a column.   What you have to do is change all the cells that are on top of each other until you create the illusion of a single column.  I think you're really going to have to spend some time with a basic table primer, like wikipedia:Help:Table to get the mentality of working with tables.  Once you understand a bit more about wiki markup for tables then you can start asking more specific questions and we can help you better.  At the end of the day, though, the only way you're going to get truly universal infoboxes is to learn something about CSS coding and hardwire all your styling declarations.  Otherwise, you're going to find that your infoboxes will have a lot of subtle variations.


 * I invite you to stare as long as you need to at tardis:MediaWiki:Common.css (searching for the term "infobox") until you sort of start to understand what's going on. You'll also need to look at something like tardis:Template:Infobox Story.  Everything that's a class definition (i.e. "class=whatever") is defined in the CSS, so that every time i say   it pulls up the style associated with "info-left", and it always looks the same.  Thus, "info-left" is a standard, known  component of an infobox, and if you define each element of the infobox, eventually you have the whole thing built.  That probably doesn't make a lot of sense right now.  But I think if you compare Template:Infobox Story to the CSS code, eventually it will make sense.   02:59: Thu 19 Apr 2012