RationalWiki's 2018 Fundraiser

There is no RationalWiki without you. We are a small non-profit with no staff — we are hundreds of volunteers who document pseudoscience and crankery around the world every day. We will never allow ads because we must remain independent. We cannot rely on big donors with corresponding big agendas. We are not the largest website around, but we believe we play an important role in defending truth and objectivity.

If everyone seeing this today donates $5, we will meet our goal for 2018.

Fighting pseudoscience isn't free.
We are 100% user-supported! Help and donate $5, $20 or whatever you can today with PayPal Logo.png!

Donations so far: $2397Goal: $5000

Help:Random choice

From RationalWiki
Jump to: navigation, search

New style (parserfunction)[edit]

To choose between one or more options, use the choose parserfunction. The format is similar to using templates:


Note that the first option does not have a | (pipe) character before it, all others do.

If you'd like some options to be shown more often than others, you can add a weight before the option, like so:

2=This option will be shown twice as often as a normal option.
|By default, options have a weight of 1.
|1.5=This option also has a weight of 1.  Fractional portions are ignored.

Warning: If an option contains an = sign, you can't omit the weight, so for example

{{#choose:option 1 has no equal sign|option two has an = sign}} 

is invalid (the weight of option two will be 0); instead just specify the weight explicitly:

{{#choose:option 1 has no equal sign|1=option two has an = sign}}


Like templates, parser functions can also be substituted. {{subst:#choose:foo|bar|baz}} will select one option when you save a page and will replace the choose function with the text of that option. However, substitution is not recursive, so if a template using choose is substituted, the entire choose function with all the options will be copied into the page text, which is probably not what you want.

The simple solution is to use subst:expand: instead of subst:, e.g.:


will take Template:Assquote, recursively substitute every template and parser function in it, and then copy the resulting text into the page when it is saved:

"Anonymous User" (sounds like another self-centered liberal, like Obama), you have free will and can laugh at anything that you can persuade yourself to be funny. I skimmed through your recent edits and there is an anti-Christian tone to your postings, so admit it, you're a supporter of infanticide. Furthermore, you are in denial that preaching about Hell prevents abortion. Got news for you: the Bible is the most logical book ever written. Lots of people are learning that, surprise, surprise, the law applies to vandalism on the internet too. Come back when you can learn out to spell "superior".--Aschlafly 18:26, 15 June 2017 (UTC)

Sometimes you don't want every template substituted. In this case, instead of using subst:expand:, you should change subst: to safesubst: and add includeonly around the safesubst: in the template's choose function, and then use normal substitution:


Unlike transcluded random templates, which change with every reload of the page, substituted templates will remain the same. Transcluded templates increase page loading times, and if they are used on a lot of pages, editing them will slow down the entire site for a long time.

Old style (tag)[edit]

Using the parser function is preferable, but you can also use the <option> tag, like so:

<option>This is the first choice.</option>
<option>This is the second choice.</option>
<option>And so on...</option>

From each set of <choose> tags, precisely one <option> tag will be selected at random, and its contents shown.

If you'd like some options to be shown more often than others, you can add weight to the option tags, like so:

<option weight="2">This option will be shown twice as often as a normal option.</option>
<option>By default, options have a weight of 1.</option>
<option weight="1.5">This option also has a weight of 1.  Fractional portions are ignored.</option>

Anything can be placed inside of option tags: links, images, even templates. However, template parameters will not be expanded, so they cannot be used in the option text or as a weight. Magic words (such as {{CURRENTDAY}}) and parser functions (such as {{#if:...}}) cannot be used as a weight. The option tag cannot be substituted either. In those cases, you can use the parser function version.

See also[edit]