Extension:RandomInclude

Introduction
RandomInclude is an extension to MediaWiki that includes in the page a text selected at random from a list.

It is based on the RandomText extension.

Features

 * Can be used inline or through transclusion.
 * Supports wikitext.

Installation

 * 1) Download RandomInclude.php and save it in the extensions directory of your wiki.
 * 2) Insert this line in the LocalSettings.php file:

Configuration
There are several variables to be used for general configuration and as default values.

These vars can be tailored on individual basis in each call to the tag function, or the parser function, named accordingly.

The format string is a four element string; start list, start item, end item and end list. The string accepts aliases for common wikiconstructs like ²{ and }² for 🇦🇩, ²[ and ]² for and  , broken pipe (¦) for pipe (|) and '\n' for linebreaks. In addition there are keywords %ITEM% for each included item and %COUNT% for the position in the output list.

Parser cache is automatically disabled for pages that use the RandomInclude extension. If for any reason the random text on the page only changes when you edit or purge the page, you can try disabling the cache for the whole wiki. Notice that doing this will affect the performance of the wiki.


 * To disable the page cache insert these lines on LocalSettings.php:
 * To give the page cache an expiration time insert these lines on LocalSettings.php:

Usage
The seed attribute can interfere with other functions and should generally be avoided.

The hash attribute is typically used to take some textual value and turn this into a numeric index. By generating this from date and time information, together with page specific information very specialized schemes for random updates can be created.

Inline
You can list the alternative random texts directly on the page in which they should appear:

Random quote of the day:

Absence makes the heart grow fonder.

Actions speak louder than words.

An ounce of prevention is worth a pound of cure.

Wikitext can be used here.

Note that this example uses the previous default pattern to separate entries; to use this with the current version, use the following configuration line instead:

Through transclusion
For larger lists of random texts, it will be better to create a template with the random texts and to include it on a separate page. This way, you can read and verify all random texts. This is especially useful if the random texts can have several lines and use wiki markup.

For instance, create a template called with this content:

Absence makes the heart grow fonder.

Actions speak louder than words.

An ounce of prevention is worth a pound of cure.

Tip
Titles and wikitext can be used here.

On the page that will show the random text, use this:

Random quote of the day:

You can even create several separate random text templates and include a random text from one of them like this:

Random quote of the day:

Alternatives

 * RandomArea
 * RandomText

Feedback
Use the discussion page for feedback, questions, feature requests and bug reports.