Fandom Developers Wiki
No edit summary
No edit summary
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Languages}}
+
<noinclude>{{LangSelect}}</noinclude><includeonly>{{Languages}}
 
 
{{Infobox JavaScript
 
{{Infobox JavaScript
 
| Image file = AddRailModule.png
 
| Image file = AddRailModule.png
| Description = Adds a custom module to the Wikia Rail
+
| Description = {{{description|Adds a custom module to the Wikia Rail.}}}
 
| Scope = s
 
| Scope = s
 
| Author =
 
| Author =
Line 12: Line 11:
 
| Type = site
 
| Type = site
 
}}
 
}}
 
{{{intro|'''AddRailModule''' adds a custom module to your wiki's side rail. By default, it adds the contents of <code>Template:RailModule</code> 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 <code>section.railModule.rail-module</code>.
 
'''AddRailModule''' adds a custom module to your wiki's side rail. By default, it adds the contents of <code>Template:RailModule</code> 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 <code>section.railModule.rail-module</code>.
 
   
 
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.
 
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.
  +
}}}
 
  +
== {{i18n|getMsg|Documentation|installation}} ==
== Installation ==
 
 
{{Script Install
 
{{Script Install
 
| Use = S
 
| Use = S
Line 23: Line 21:
 
}}
 
}}
   
  +
== {{i18n|getMsg|Documentation|configuration}} ==
== Configuration ==
 
To add the contents of <code>Template:RailModule</code> as a module towards the top of the side rail:
+
{{{configInfo|To add the contents of <code>Template:RailModule</code> as a module towards the top of the side rail:
   
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
Line 64: Line 62:
 
];
 
];
 
</syntaxhighlight>
 
</syntaxhighlight>
  +
 
{{ConfigOptions}}
 
{{ConfigOptions}}
  +
}}}
   
== Styling ==
+
== {{{styling|Styling}}} ==
To target all custom modules, use the selector <code>.railModule</code>.
+
{{{stylingInfo|To target all custom modules, use the selector <code>.railModule</code>.
   
 
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 ==
+
== {{{advanced|Advanced usage}}} ==
If your module makes use of parser tags like <code>&lt;gallery/&gt;</code> or <code>&lt;twitter/&gt;</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'''.
+
{{{advancedInfo|If your module makes use of parser tags like <code>&lt;gallery/&gt;</code> or <code>&lt;twitter/&gt;</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'''.}}}
  +
</includeonly>

Revision as of 10:01, 14 April 2020

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.

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:

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.

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.

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.

Text above can be found here (edit)