m (Mention polls as an example of the type of frequently updated content for which caching should be disabled) |
(→Advanced usage: Mention integration with Rewire) |
||
Line 62: | Line 62: | ||
To target specific custom modules, consider wrapping the contents of each module in their own unique container element in your templates, and selecting that instead. |
To target specific custom modules, consider wrapping the contents of each module in their own unique container element in your templates, and selecting that instead. |
||
+ | |||
+ | == Advanced usage == |
||
+ | If your module makes use of parser tags like <code><gallery/></code> or <code><twitter/></code>, you may find that they don't load properly. If this is the case, check whether they're listed under [[Rewire#Support|Rewire § Support]], and if they are, add <code>dev:Rewire.js</code> to your '''MediaWiki:ImportJS'''. |
Revision as of 06:51, 12 November 2019
AddRailModule adds a custom module to your wiki's side rail. By default, it adds the contents of Template:RailModule
towards the bottom of the side rail (just above the recirculation module). With configuration, multiple modules can be added, and up to two modules can be placed towards the top of the side rail (just below the top ads module). Each module is wrapped in a section.railModule.rail-module
.
Installation
Configuration
To add the contents of Template:RailModule
as a module towards the top of the side rail:
window.AddRailModule = [{prepend: true}];
To add multiple modules (e.g., the contents of Template:Foo
, Template:Bar
, and Template:Baz
) towards the bottom of the side rail:
window.AddRailModule = ['Template:Foo', 'Template:Bar', 'Template:Baz'];
To add multiple modules towards both the top and bottom of the side rail:
window.AddRailModule = [
{page: 'Template:Foo', prepend: true},
'Template:Bar',
'Template:Baz',
];
NB: If you specify more than two modules for prepending, only the first two will be honored.
window.AddRailModule = [
{page: 'Template:Foo', prepend: true}, // okay
{page: 'Template:Bar', prepend: true}, // okay
{page: 'Template:Baz', prepend: true}, // not okay; will be added towards the bottom of the side rail instead
];
The contents of each module may be cached for up to maxAge
seconds. By default, this is 300 seconds (five minutes). If your module is short-lived—i.e. it updates often (like polls), or is random in nature, or relies on page name variables like {{PAGENAME}}
—then set maxAge
to 0 seconds. Conversely, if your module is long-lived, then maxAge
can be set up to 86,400 seconds (one day).
window.AddRailModule = [
{page: 'Template:RandomGreeting', prepend: true, maxAge: 0},
{page: 'Template:FAQs', maxAge: 86400},
];
Using configuration options with Fandom Developers Wiki scripts
The instructions on this page describe how to use configuration options with a script. Here on the Fandom Developers Wiki, many scripts provide optional configuration settings as a mean to alter or enhance the default behavior of the script. When installing configuration options in your JavaScript file, please note that they need to go above the import statement in order to work — unless the directions say otherwise. In case MediaWiki:ImportJS
is used to load the scripts, it will be executed last.
// 1. AjaxRC import statement
importArticles({
type: 'script',
articles: [
'u:dev:MediaWiki:AjaxRC.js'
]
});
// 2. AjaxRC configuration option
window.ajaxRefresh = 30000;
// 1. AjaxRC configuration option
window.ajaxRefresh = 30000;
// 2. AjaxRC import statement
importArticles({
type: 'script',
articles: [
'u:dev:MediaWiki:AjaxRC.js'
]
});
Styling
To target all custom modules, use the selector .railModule
.
To target specific custom modules, consider wrapping the contents of each module in their own unique container element in your templates, and selecting that instead.
Advanced usage
If your module makes use of parser tags like <gallery/>
or <twitter/>
, you may find that they don't load properly. If this is the case, check whether they're listed under Rewire § Support, and if they are, add dev:Rewire.js
to your MediaWiki:ImportJS.