User:Slayingthehalcyon/saving

So some of you may have seen the. Well, have no fear, because there is almost always a solution to the problem! This blog will hopefully have you coding with the #if and the #switch by the time you're done reading!

The Code
Here below, I have a selection of coding from a wiki for a TV show, the coding will be understandable to some users, which is a good thing! For those of you who have absolutely no clue what all this does, don't worry, I'm going to break it down bit by bit, and show you which piece I'm talking about as I break it down. c: Lets get started!

Breaking down the If
Okay so first of all we have the following code: {{#if: {{{seasons|}}}|

Now, to call up an #if, we have to use two "{" brackets, just like when we call up any other template. (Make sure you close it with two "}" brackets before you publish your work! Otherwise your coding won't work.) Now the {{{seasons|}}} is what the #if statement is looking for. The {{{seasons "|" }}} means that if you don't enter something into the seasons field, you don't see {{{seasons}}} in your published template.

Now, an #if statement looking for something? What, simple, all the #if is doing, is checking to see if we put  in our template! "Why would it do that?" you might ask. Well, this is so that we can hide certain information rows on a template! This is useful if you don't always want the row for a character's season listing to show up. This way, only the information that is entered, shows up on the template. This also means, that if a character doesn't have a large seasonal role in the TV show, you can leave leave  out of the template entirely!

To put this into better perspective, say I've made a page for Shawn Spencer, Psychic Detective. In his infobox, with our nifty coding, when I put in  it puts the text, "my season is on fire" in the template when we hit publish. Now if we had left it blank, the row with the information for seasons won't even show up when we hit publish!

The Styling
This gives us the following look:

Now if we add  to our row style, we get the field.