FANDOM


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

Installation

See also: Help:Including additional CSS and JS, Help:Advanced CSS and JS
  • For site-wide use, an administrator can add the line below to the wiki's MediaWiki:ImportJS page. Note that JavaScript must be enabled on the wiki.
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 Open Source Library scripts
The instructions on this page describe how to use configuration options with a script. Here on the FANDOM Open Source Library, 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
Proper placement of configuration options
// 1. AjaxRC import statement
importScriptPage('AjaxRC/code.js','dev');
 
// 2. AjaxRC configuration option
var ajaxRefresh = 30000;
// 1. AjaxRC configuration option
var ajaxRefresh = 30000;
 
// 2. AjaxRC import statement
importScriptPage('AjaxRC/code.js','dev');


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 Set the name of the subpage that every template will use to store the premade syntax. If the value case-by-case is used, no subpage will be added to the template list which must contain the list of complete paths. 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>
[[Category:Preload pages]]
</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>
[[Category:Name]]
</no<includeonly></includeonly>include></includeonly>

which will result in

<noinclude>
[[Category:Name]]
</noinclude>

once preloaded.

Localization

To add or edit translations for this script, use the translations editor.

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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.