Forum:Give templates different use choices: how?

I didn't know how to ask this, but I think you'll get what I'm speaking about with a simple example:

RaceIcon

As you see, this template has some folders that make the template show different things depending on the value they have.

My question is: How do I write the code for defining those folders?

What I want to make is an userbox that, depending on the number you put, changes a word in the text and shows a different image. I could make different templates for each case, but they are many and I think this could be a better option, and also easier to understand by the users.

I suspect it's related with the type of coding; if I'm right, just translate me the ways of putting "if"s and the basic commands. I know enough programming to get the code idea, but I don't know anything about the language.

It's something I always wanted to know, and I think this could be the perfect chance to get to know how to, and be able to build better ones in the future .--Lon-ami (talk) 19:46, October 11, 2009 (UTC)
 * See mw:Help:Extension:ParserFunctions. -- 19:59, October 11, 2009 (UTC)


 * Thanks! That was just what I needed. I'll give it a read, and try to build the template. I'll post my results here later .--Lon-ami (talk) 17:39, October 12, 2009 (UTC)

Switching with values between two numbers
Ok, so I got to understand this, more or less.

Now, I only don't know how to, instead of this:



Make something like this (rough):



I want to work with high values (1-50, 50-100, 100-250, 250-500, 500-1000, 1000-2500...) and I don't know how to build those ranges :S. I'm sure it's pretty simple, but I fail to find the solution.

I need it for 2 things:
 * Display a text depending on number range.
 * Display a image depending on number range (I don't know if images need a special code or something for working properly).

Thanks!--Lon-ami (talk) 18:44, October 26, 2009 (UTC)


 * You may want to use #ifexpr rather than #switch in this case. Or maybe you can combine the two, but I've never done it. -- Fandyllic  (talk &middot; contr) 10:33 PM PST 26 Oct 2009


 * I think I'll just go for "nested" (dunno if it's well said) ifs, something like this:




 * This checks if x is bigger than 0, and if it's true, then it checks if y is bigger than 0. Repeat this proccess, let's say, 20 times, and there you have, the perfect result. Now I only need to search the proper images and it'll be done .--Lon-ami (talk) 21:11, October 31, 2009 (UTC)


 * Damn, I knew this was too easy.
 * So, I have a new problem: I don't know how to introduce variables into the ifexpr. I try, but it fails.
 * Any ideas?--Lon-ami (talk) 21:26, October 31, 2009 (UTC)


 * I think it has something to do with this:
 * 
 * Will check and ask again tomorrow if I can't solve this up :S.--Lon-ami (talk) 21:58, October 31, 2009 (UTC)


 * I suspect #ifexpr is not supported on WoWWiki. I tried to get it to work on a test template, but it kept giving me an error. I also noticed our version of ParserFunctions is 1.1.1, but the one running on mediawiki.org is 1.3.0.
 * You could try using:
 * It is supposed to be the equivalent. I made a test range checking template at User:Fandyllic/rangetest as an example to try out some range checking.
 * Output:
 * Output:
 * Output:
 * Output:
 * -- Fandyllic  (talk &middot; contr) 6:01 AM PST 1 Nov 2009
 * Output:
 * Output:
 * -- Fandyllic  (talk &middot; contr) 6:01 AM PST 1 Nov 2009
 * -- Fandyllic  (talk &middot; contr) 6:01 AM PST 1 Nov 2009


 * WHoA, thanks a lot. So it was that, damn, and me trying and trying with the damn ifexpr. It doesn't matter, it works now, an d that's what matters :P.
 * Anyway, just as a curiosity, what is that | 0 | for?
 * That's all. I'm gonna check if it works properly with images now, and will return else to show the finished template or more doubts .--Lon-ami (talk) 15:28, November 3, 2009 (UTC)


 * basically means "false".
 * You could use  instead, I believe, and then the wikicode would just be slightly different:
 * -- Fandyllic  (talk &middot; contr) 6:38 PM PST 3 Nov 2009
 * -- Fandyllic  (talk &middot; contr) 6:38 PM PST 3 Nov 2009


 * Yeah, it seems the true and false folders switch between them. Anyway, implemented it with anything (guess it reads as default 1) and everything worked fine. This was just an experiment to try these functions, but I'm definitely going to apply these anywhere I see it can be applied :


 * Again, thanks for the help ;).--Lon-ami (talk) 20:45, November 3, 2009 (UTC)