Fandom Developers Wiki
Advertisement

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 recommendations module ("Others like you also viewed" or "Popular Pages") or sticky modules ("Page Tools" or "Recent Wiki Activity"). 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.

There is a limit to the number and height of the allowable rail modules. The height of the overall size of added rail modules should not be taller than the regular rail modules. Also, only one rail module is allowed to be above (prepended) the Recent Wiki Activity module.

Installation

Configuration

To add the contents of Template:RailModule as a module towards the top of the side rail, add this to your Common.js:

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',
];

Note: 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).

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.

Configuration options load too late, don't work
// 1. AjaxRC import statement
importArticles({
    type: 'script',
    articles: [
        'u:dev:MediaWiki:AjaxRC.js'
    ]
});

// 2. AjaxRC configuration option
window.ajaxRefresh = 30000;
Proper placement of configuration options
// 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.


Forks

NewPagesModule

After you've installed the script, copy the following contents to the Template:NewPagesModule page on your wiki:

<h2>{{int:newpages}}</h2>
<div class="new-pages-rail-module">
{{Special:NewPages/4}}
<div class="more">'''[[Special:NewPages|{{int:oasis-more}}]]'''</div>
</div>

Also import the script's stylesheet to customize the module:

And add your template to following parameters (in addition to those already connected; if there are none, then only one template):

window.AddRailModule = ['Template:Foo', 'Template:Bar', 'Template:Baz', 'Template:NewPagesModule'];
Text above can be found here (edit)
Advertisement