MakeArticle is an extension that, given a template, presents the user with a form in which they can fill in:

  • An article name
  • Values for the template's parameters

When they then click the 'create' button , it builds an article with that name based on the template parameterised by those values.

Essentially, it takes the idea from extensions like CreateArticle and extends it by allowing the text pre-loaded into the new page to be configurable on the fly, so one can specify any template in the markup and create a parameterised article. So it provides a handy tool for creating new pages by filling in a form.


The extension takes a two-pass approach:

  1. Building a web-form based on the structure of the specified extension. This uses the hook ParserFirstCallInit.
  • This includes using a style-sheet to format the form, that the wiki manager can customise)
  1. In response to the button-click, using the provided parameter values to build a new article and take the user there. This uses the hook UnknownAction.

Pass One : Hook ParserFirstCallInitEdit

This pass registers a loader function with the hook, the loader function associating the tag <makearticle> with the function wfMakeArticle (line 40). This creates an instance of the class MakeArticle (line 46) and then invokes the member function render() of that instance.

The function render():

  1. Uses the stylesheet pointed to by the global variable $wgMakeArticleCSS (defaults to $IP/extensions/makearticle/Style.css) to insert formatting information into a page header.
  2. Attempts to read in the contents of the template file named in the text between the tags.
  3. Extracts the names of the parameters from the template.
  4. Builds an HTML form styled by the stylesheet which:
  1. Asks the user for a name for the new article to be created.
  2. Asks for values for the template's parameters.
  3. Provides a 'create' button.

When the user hits 'create' the form sends this information back to MediaWiki, together with additional parameters:

  • The name of the template.
  • An identifier tag ___makePage to allow the second pass to identify which UnknownActions belong to this extension.

Pass Two: Hook UnknownActionEdit

This pass registers the function wfActionMakeArticle (line 127) with UnknownAction. The function filters out those events that are relevant by looking for the ___makePage tag. It then:

  1. Attempts to create a new article with the specified name.
  2. Inserts into the article the text:
    {{{template name | parm1="value1" | . . .}}}
  3. Redirects MediaWiki to the new page.

The StylesheetEdit

The stylesheet is used to format the web form generated in pass 1. Here is a quick run down of what it does:

Class Function
.mpForm Applies to the <div> encompassing the entire form. Essentially used to set the total width of the form.
.mpForm h2 Formats the form's heading.
.mpR Additional formatting for the name of the template in the heading (default is red text).
.mpTable Formats the table containing the parameter names and textareas.
.mpForm textarea Formats textareas used for user input; includes setting height and a width hack to stop them overlapping at the right-hand edge of the table.
.mpForm textarea.mpSingle Used for the textarea containing the page name, to make it a different height to the parameter textareas.
.mpHeader Sets the width of the field-name column.
.mpForm td Formats table cells; background colour, border, etc.
.mpButton Formats the 'create' button.


I would like to acknowledge the following extensions:

  • CreateArticle by Lisa Ridley, from which I took the basic two-pass approach.
  • PageCSS by Ævar Arnfjörð Bjarmason, from which I took the code to inject a CSS into the generated page containing the form.