Help:Wiki University Wikitext--Infobox - If functions

Infobox Content

 * In our example from the last lesson, we had limited the items shown for our organization for illustration purposes. But as you know many organizations have far more offices and other items that would be worth knowing that should be in these infoboxes.
 * It would be better to create a infobox with more items to cover all possiblies. However the problem is that the posted infobox could have a lot of blank spaces if it is a small organization.
 * What we would like to happen then is when a parameter is not filled in, that is does it show. In other words, if the organization does not have a phone number, there will not be a line or a blank space for it.

If functions

 * It is possible to code the infobox so that the item like a "phone" does not appear if there is none.
 * We will now introduce you to another attribute called if functions.
 * It is bit of coding added to the title of the item in the first column.
 * This is an example of adding the if function code to the row for naming the President:

We know that there are a lot of curly brackets here but pay close attention:
 * NOTICE the {{#if:{{{president|}}} added to the first cell.
 * NOTICE the pipe after the word "President."
 * NOTICE the two closing curly brackets at the end of where the name actually goes in the second cell.
 * This coding looks a bit intimidating but it is really not that hard. For further insight see: if functions

You can create long infoboxes
With this coding, you can create a complete infobox that covers all the items you think are necessary, but has the ability to shrink the infobox if not all the items are present such as a vice president or web site address.
 * These "if functions" allow you to create long and detailed infoboxes, with the ability to shrink down to the amount of information you have entered. An organization with a large staff can be posted in a long infobox as well as a small organization with a much shorter infobox using the same infobox template.

Placing the extended infoboxes
But when we place it, looks like this, this is what we will see after it is posted.
 * Placing these longer infobox is done exactly as our example.
 * The difference is if nothing is entered after the equal sign, that line in the infobox will not show after it is posted or edited.
 * So if our finished infobox looks like this:

Try these out


 Exercises

Use this coding for this exercise: Lets make this into a infobox: Check your answers
 * 1) Put a border around the infobox, limit the width to 190 pixels and make it so that will always be on the right side of the page.
 * 2) Put borders around each of the cells.
 * 3) Have the cells containing the words organization and image span both columns.
 * 4) Center the name of the organization and the image in their cells.
 * 5) Make the items in the right hand cells into parameters.

 Quick Quiz
 * Parameters have two opening and closing curly brackets surrounding them.
 * A. True
 * B. False


 * Infoboxes usually are located at the top of the page on the right side.
 * A. True
 * B. False


 * Infoboxes are saved just like other templates but it is good practice to included the word "infobox" in its title.
 * A. True
 * B. False

Check your answers