Erweiterung:RandomSelection
Freigabestatus: stabil |
|
|---|---|
| Einbindung | Tag, Parser-Funktion |
| Beschreibung | Displays a random option from the given set |
| Autor(en) | |
| Letzte Version | 3.0.0 (2018-09-09) |
| MediaWiki | 1.43+ |
| Datenbankänderungen | Nein |
|
|
|
| Lizenz | GNU General Public License 2.0 oder neuer |
| Herunterladen | |
| Beispiel | |
| Übersetze die RandomSelection-Erweiterung, wenn sie auf translatewiki.net verfügbar ist | |
The RandomSelection extension allows for randomly-generated content inside your wiki; e.g. rotating images, random greetings, etc.
Installation
- Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens
RandomSelectionim Ordnerextensions/ablegen.
Entwickler und Code-Beitragende sollten stattdessen die Erweiterung von Git installieren, mit:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/RandomSelection
- Folgenden Code am Ende deiner LocalSettings.php-Datei einfügen:
wfLoadExtension( 'RandomSelection' );
Erledigt – Navigiere zu Special:Version in deinem Wiki, um zu überprüfen, ob die Erweiterung erfolgreich installiert wurde.
Verwendung
Tags
To choose between one or more options, simply place each option inside an <option> tag which are themselves placed inside <choose> tags, like so:
<choose>
<option>This is the first choice.</option>
<option>This is the second choice.</option>
<option>Und so weiter...</option>
</choose>
From each set of <choose> tags, precisely one <option> tag will be selected at random, and its contents shown.
Anything can be placed inside of option tags: links, images, even templates.
You can also have what is placed inside the option tags be sent as an argument to a template with the <choicetemplate> tag, e.g.:
<choose>
<option>Template:Featured article/Elephant</option>
<option>Template:Featured article/Giraffe</option>
<option>Template:Featured article/Rhinoceros</option>
<choicetemplate>PageWithEditButton</choicetemplate>
</choose>
You could then create a [[Template:PageWithEditButton]] with these contents:
[{{canonicalurl:{{{1}}}|action=edit}} Edit] {{{{{1}}}}}
This is useful if you want to set up randomly rotating featured articles and have an edit button to allow the user to edit the featured article blurbs.
Parameter für choose
| Parameter | Beschreibung |
|---|---|
uncached
|
Disable caching for the chosen option |
before
|
Put this text before the chosen option |
after
|
Put this text after the chosen option |
<choose> tag is disabled only if the user specifies <choose uncached>. Previously caching was disabled by default.If you wanted to disable caching for the options, you should add the uncached parameter.
<choose uncached>
<option>This is the first choice.</option>
<option>This is the second choice.</option>
<option>Und so weiter...</option>
</choose>
If you wanted to display one of three YouTube videos, you could try this (Extension:Widgets and Erweiterung:YouTube required):
<choose before="{{#widget: YouTube|id=" after="}}">
<option>eR7-AUmiNcA</option><!--King of Anything-->
<option>cSCi7kCXKDA</option><!--Slipping Through My Fingers-->
<option>7n2d9XPsmmE</option><!--When Death Note Music Plays in My Car-->
</choose>
Parameter für option
| Parameter | Beschreibung |
|---|---|
weight
|
Weight of the option |
If you'd like some options to be shown more often than others, you can add weight to the option tags, like so:
<choose>
<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>
</choose>
Parserfunktion
To choose between one or more options, simply place each option inside the #choose: parser function, like so:
{{#choose:
|This is the first choice.
|This is the second choice.
|Und so weiter...
}}
From each choice divided by a pipe, precisely one choice will be selected at random, and its contents shown. Anything can be placed inside: links, images, even templates.
Siehe auch
- Erweiterung:RandomImage — Allows for randomisation of multimedia content on a page
| Diese Erweiterung ist in den folgenden Softwarepaketen enthalten und/oder wird von den folgenden Wiki-Farmen, bzw. Wiki-Hostern verwendet: |
- Stable extensions/de
- Tag extensions/de
- Parser function extensions/de
- MagicWordwgVariableIDs extensions/de
- ParserFirstCallInit extensions/de
- GPL licensed extensions/de
- Extensions in Wikimedia version control/de
- All extensions/de
- Extensions included in Canasta/de
- Extensions included in Fandom/de
- Extensions included in Miraheze/de
- Extensions included in MyWikis/de
- Extensions included in ShoutWiki/de
- Extensions included in wiki.gg/de
- Random content extensions/de
