Template:Random/doc: Difference between revisions
m (Bot: Adding <noinclude>{{PAGENAME}}</noinclude>) |
|||
Line 14: | Line 14: | ||
Test it out by reloading this page several times. What you get below will be different on ''almost'' every page, though with a sample size of only 52, you're bound to get some repeats. The reason is because there are 53 pages in the following format:<pre>{{qotw/n}}</pre>However, there is no {{tlx|qotw/0}}. Thus by adding 1 to the randomly selected number between 0 and 52, we ensure the choice will be between the numbers 1 and 53. | Test it out by reloading this page several times. What you get below will be different on ''almost'' every page, though with a sample size of only 52, you're bound to get some repeats. The reason is because there are 53 pages in the following format:<pre>{{qotw/n}}</pre>However, there is no {{tlx|qotw/0}}. Thus by adding 1 to the randomly selected number between 0 and 52, we ensure the choice will be between the numbers 1 and 53. | ||
<div id=license>{{qotw/{{#expr:{{random|52}} +1}}}}</div> | <div id=license>{{qotw/{{#expr:{{random|52}} +1}}}}</div> | ||
<noinclude>[[category:template documentation|{{PAGENAME}}]]</noinclude> |
Revision as of 14:01, 18 May 2012
{{random}} generates a random number, at least to the extent that non-mathematicians will be happy with the term "random", through simple markup. The number can be from 1 to whatever number you choose, up to 1000.
Syntax is straightforward:
{{random|1000}} = 293
This number will change every time the page loads.
Though this simple aspect is enough to power any number of functions — such as determining which random, numbered subpage to call on a page, the template does have additional sophistication, detailed at template:random on Wikipedia.
Example of calling forth a page
If you type the following, you will get a different quote of the week on every page load:
{{qotw/{{#expr:{{random|52}} + 1}}}}
Test it out by reloading this page several times. What you get below will be different on almost every page, though with a sample size of only 52, you're bound to get some repeats. The reason is because there are 53 pages in the following format:
{{qotw/n}}
However, there is no {{qotw/0}}. Thus by adding 1 to the randomly selected number between 0 and 52, we ensure the choice will be between the numbers 1 and 53.
- Second Doctor: Polly Wright, did I ever thank you for always being here for me? Especially when I most needed someone, when I . . . well, let's just say that without your help, I wouldn't be the man I am. You are an extraordinarily resourceful and compassionate young woman. And one day, you will work out what it is you're meant to do with your life. And you will do it magnificently. You will make a real difference — I can promise you that. Just do me this one favour, would you? Don't make that difference here, not in the past. I want you to change the future!