Language: | English • 日本語 |
---|
![]() |
Please note: Some techniques recommended in this article require the use of extensions. Please use with care. The status assigned to each extension is self-assigned by the maintainer and does not represent the opinion of the MediaWiki development team. |
Preloading wikitext presents the user with a partially created page, possibly with inline instructions for content organization, rather than a blank page. This technique is especially useful when the wiki contains one or more categories of articles, with lots of pro-forma text or the information that needs to be collected for such articles is a mix of structured data and free form text.
Creating pages with preloaded text is a three step process:
- Design the preload file and its supporting templates
- Create pages for the preload files and supporting templates
- Set up the trigger to load the preload file
Designing the preload fileEdit
The preload file is often an article with an embedded template. For example, if you wanted one article for each customer or marketing contact, you might want to preload text that looks something like the example below.
<!-- Please enter your customer's contact information after the equal sign. If you need help uploading the business card images, please see [[Help:Uploading business card images]] --> {{CustomerContact |Number= |BizcardImage= |Primary phone number= |Address= }}
Naming and documenting the preload fileEdit
Some extensions (see Extension:Boilerplate) have specific expectations as to where the preloaded text should be stored. Others leave that decision entirely up to the system administrator.
Naming and documenting the preload file takes some care, because preload files don't always show up on "What links here" and so are at risk for accidental deletion (no info/no links - hard to tell from an article that got created and abandoned). For template based preload files, the following naming conventions may help avoid accidental deletion:
- place template in
Template:CategoryName
- place preload file in
Template:CategoryName/Preload
Note: before the fixing of bug 5210, preload templates could not contain documentation, categories, interlanguage links etc - all content would affect the preload output. With bug 5210 fixed, <noinclude> tags now work as expected.
Loading the preload fileEdit
Preloading can be done with a preload parameter in a URL like http://en.wikipedia.org/wiki/Talk:Main_Page?action=edit§ion=new&preload=Template:Foo which links to the edit box of a new page, preloaded with Template:Foo. There are also a number of extensions available to trigger your preload file, see below.
The wikitext of the source page is preloaded into the editbox if the page or section does not exist yet. If the page or section to be edited already exists then only its wikitext is loaded, the preload command is ignored.
Notes:
- In MediaWiki versions before 1.17, both the <noinclude> and </noinclude> tags AND their content are preloaded, which means you can't categorize the source page or include some self-documentation: it'd be dumped into the preloaded text too. As of MediaWiki 1.17, these are now removed; if you need the preloaded text to provide noinclude tags, you can use
<no<includeonly></includeonly>include>
- The <includeonly> and </includeonly> tags are stripped from the source page. If you need the preloaded text to provide includeonly tags, you can use
<include<includeonly></includeonly>only>
Thus there is neither a complete inclusion nor a regular transclusion. See also bug 5210 (since 2006-03-09).
If it is creating a new section, the initial content of the "Subject/headline" box can be provided with the parameter "preloadtitle"
If it is not creating a new section, the summary can be set with the summary parameter (bug 17002).
- http://meta.wikimedia.org/w/wiki.phtml?title=Meta:Sandbox&action=edit&summary=Doing%20some%20changes
The minor edit checkbox can be set by adding minor parameter
Using parametersEdit
MediaWiki version: | ≥ 1.23 |
You can also specify parameters to the preload text with the preloadparams[]
url parameter (When linking on wiki, you may want to escape the []
to be %5b%5d
. Each parameter specified replaces a $1, $2, ... variable. For example http://mediawiki.org/wiki/Project:Sandbox?action=edit§ion=new&nosummary=true&preload=Manual:Creating_pages_with_preloaded_text/param_demo vs http://mediawiki.org/wiki/Project:Sandbox?action=edit§ion=new&nosummary=true&preload=Manual:Creating_pages_with_preloaded_text/param_demo&preloadparams%5b%5d=first%20value&preloadparams%5b%5d=second%20value
ExtensionsEdit
Extensions that trigger a preload file include:
- Extension:BoilerRoom
- Extension:Boilerplatefactory
- Extension:Preloader
- Extension:Inputbox, Extension:CreateBox, Extension:CreateArticle offer the most control over the loading process. Each of these extensions let you place a button somewhere in an article, typically in a user help page or the category page corresponding to the article. You specify the name of the preload file as part of the button definition.
- Extension:MultiBoilerplate
- Extension:BoilerplateSelection - preloaded text selected by pattern matching on article title. To set this up you create an array in your Manual:LocalSettings.php file. This array associates regular expressions with preload article names.
- Extension:Boilerplate - preloaded text for all articles irrespective of name or category. The preloaded text must be stored in the MediaWiki article
[[MediaWiki:Boilerplate]]
. It will be loaded automatically whenever an article is created. - Extension:PreloadManager - Provides per-namespace specific text preloading upon page creation.
A few extensions also handle all three steps for you:
- Extension:Add Article to Category - puts an add-an-article button on each category. When an article is created using this extension it will automatically contain the wiki text for including the article in that category, i.e. [[Category:...]]
- Extension:Semantic Forms - Can simply preload an article page, in addition to its form features. Actually, this has been broken for about six months, so don't bother.
All extensions related to page creation are in the Page creation extensions category.