Extension:RandomSelection/pl
RandomSelection Status wydania: stabilne |
|
---|---|
Realizacja | Znaczniki , Funkcja parsera |
Opis | Displays a random option from the given set |
Autor(zy) | |
Ostatnia wersja | 3.0.0 (2018-09-09) |
MediaWiki | 1.39+ |
Zmiany w bazie danych | Nie |
Licencja | Nie określono |
Pobieranie | |
Przykład | |
|
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Przetłumacz rozszerzenie RandomSelection jeżeli jest dostępne na translatewiki.net |
The RandomSelection extension allows for randomly-generated content inside your wiki; e.g. rotating images, random greetings, etc.
Instalacja
- <translate> [[<tvar name=2>Special:ExtensionDistributor/RandomSelection/pl</tvar>|Download]] and move the extracted <tvar name=name>
RandomSelection/pl
</tvar> folder to your <tvar name=ext>extensions/
</tvar> directory.</translate>
<translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/RandomSelection%2Fpl - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'RandomSelection/pl' );
- File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>
Użycie
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>And so on...</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.
Parameters to <choose>
Parametr | Opis |
---|---|
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>And so on...</option>
</choose>
If you wanted to display one of three YouTube videos, you could try this (Extension:Widgets and Extension: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>
Parameters to <option>
Parametr | Opis |
---|---|
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>
Parser function
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. |And so on... }}
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.
Zobacz też
- Extension:RandomImage — Allows for randomisation of multimedia content on a page
File:OOjs UI icon information-progressive.svg | <translate> This extension is included in the following wiki farms/hosts and/or packages:</translate>
<translate> This is not an authoritative list.</translate> <translate> Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here.</translate> <translate> Always check with your wiki farms/hosts or bundle to confirm.</translate> |
- Pages with script errors
- Pages with broken file links
- Stable extensions/pl
- Tag extensions/pl
- Parser function extensions/pl
- Extensions with manual MediaWiki version
- Extensions with no license specified/pl
- Extensions in Wikimedia version control/pl
- All extensions/pl
- Extensions not in ExtensionJson
- Random content extensions/pl