Fandom Developers Wiki
Advertisement

PreloadTemplates allows users to insert a premade syntax from a list of selectable templates directly within the source editor.

Installation

Importing multiple scripts? This quick guide shows how to combine the imports.
  • For site-wide use, an administrator can add the line below to the wiki's MediaWiki:ImportJS page.
dev:PreloadTemplates.js

Configuration

The script can be used as it is, but it does also support these customizable variables that can be added before the import on Common.js. Common.js will run before MediaWiki:ImportJS.

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'
    ]
});
Variable Description Default value Type
preloadTemplates_list Set the page name (namespace included) with the list of templates to be preloaded. MediaWiki:Custom-PreloadTemplates string
Example:
preloadTemplates_list = "MediaWiki:Custom-PreloadTemplatesList";
preloadTemplates_subpage The name of the subpage, or case-by-case, that every template will use to store the premade syntax. preload string
Examples:
preloadTemplates_subpage = "syntax";
The code will be preloaded from the /syntax subpage.
preloadTemplates_subpage = "case-by-case";
The template list will include the complete path for each template. No subpage will be added to it.

Use

Requirements

To use the tool, you have to create the required pages:

  • MediaWiki:Custom-PreloadTemplates (or whatever you set as your template list).
    • You will add here the list of the templates you want to preload from the editor. Everything in a wikitext bulleted list (the list made by *) will be treated as a template name. Everything else will be treated as normal text.
    • You may also add a display title to by using a pipe (|) after the template name, similarly to how the wiki navigation works.
  • For each template you listed, you have to create the subpage preload (or whatever you set as your subpage).
    • Here you will add the text that you want to be preloaded as it is when the template is selected.
    • If you choose to have a case-by-case preload page, then the full path must be used on the template lists. With a case-by-case preload, it's possible to have multiple preload pages for a single template.

Both kind of pages support the use of <noinclude></noinclude> and <includeonly></includeonly> tags.

Examples

Default

Using the default configuration if on MediaWiki:Custom-PreloadTemplates we add

Generic templates:
* Template 1 | Template 1 (for characters)
* Template 2
* Template 3

Other templates:
* Template 4
* Template 5
* Template 6

With this code, clicking on any of the template listed there will add the text stored on the subpage, for example Template:Template 1/preload. The template will be listed with the display title indicated after the pipe, if added.

Custom

By using these options:

preloadTemplates_list = "MediaWiki:Custom-PreloadTemplatesList";
preloadTemplates_subpage = "case-by-case";

the template list will be retrieved from MediaWiki:Custom-PreloadTemplatesList. On that page, using this code:

Infoboxes:
* Character Infobox/preload1 | Character Infobox (ver 1)
* Character Infobox/preload2 | Character Infobox (ver 2)
* Object Infobox/preload | Object Infobox

Will create a list using the display titles after the pipe character which will preload the page indicated before the pipe.

Tags in preload page

On the preload page of a template, if we use:

<includeonly>
{{Template 1
| parameter A   = 
| parameter B   = 
| parameter C   = 
}}</includeonly>
<noinclude>

</noinclude>

When the template will be preloaded only the following code will be added to the editor:

{{Template 1
| parameter A   = 
| parameter B   = 
| parameter C   = 
}}

If you want to preload noinclude/includeonly tags (for example, if you want to add a category), you can do so by using a trick like this:

<no<includeonly></includeonly>include>

</no<includeonly></includeonly>include></includeonly>

which will result in:

<noinclude>

</noinclude>

once preloaded.

Changelog

Date Notes Updated by
October 7th, 2016 Created leviathan 89
October 9th, 2016 Added other languages, better skins support leviathan 89
October 15th, 2016 Added other languages leviathan 89
October 17th, 2017 Added display name and case-by-case support leviathan 89
November 8th, 2017 Rewritten the script using I18n-js, other fixes KockaAdmiralac
Advertisement