Extension:NewArticleTemplate

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
NewArticleTemplate

Release status: stable

Implementation User interface
Description Prefills newly created pages with some text.
Author(s) Mathias Ertl (Matitalk)
Latest version 1.1 (2008-02-06)
MediaWiki 1.9+ (tested up to version 1.21.x)
Database changes No
License GPL 3.0 or later.
Download see the download section
Changelog
Example see below
Parameters
  • $wgNewArticleTemplatesEnable
  • $wgNewArticleTemplatesNamespaces
  • $wgNewArticleTemplates_PerNamespace
  • $wgNewArticleTemplatesDefault
  • $wgNewArticleTemlatesOnSubpages
Hooks used
EditPage::showEditForm:initial

Translate the NewArticleTemplate extension if possible

Check usage and version matrix; code metrics

The NewArticleTemplate extension allows to automatically prefill text of new pages with the contents of other predefined wiki-pages. It is possible to distinguish between namespaces and specify a different text for new subpages.

Download[edit | edit source]

The source code of this extension is managed on git.fsinf.at. You can find the repository at mediawiki/newarticletemplate. To get the most recent version of this extension, fetch the current HEAD:

git clone https://git.fsinf.at/mediawiki/newarticletemplate.git

NOTE: Due to a bug in gitorious, URLs for cloning are displayed as 'git.git.fsinf.at'. Please strip one 'git'.

Older versions are marked as tags, you can view available tags with git tag -l and move back to the current HEAD with git checkout <tag-name>. Versions for older versions of MediaWiki, if available, are managed as branches, use git branch and git checkout <branch> to move to a specific branch. To move back to the newest version, use git checkout master.

Note that Gitorious allows you to download older different commits as tarball if you do not want to install git.

Installation & Configuration[edit | edit source]

The extension is probably more configurable than it needs to be. It is recommended that you use pages in the MediaWiki namespace for the templates, otherwise the templates are editable by everyone, which is probably not what you want. Here is a (hopefully) self-explanatory snippet of LocalSettings.php:

require_once ("$IP/extensions/NewArticleTemplate/NewArticleTemplate.php");
$wgNewArticleTemplatesEnable = true;
 
# enable on subpages:
$wgNewArticleTemplatesOnSubpages = true;
 
# Templates are used in these namespaces:
$wgNewArticleTemplatesNamespaces = array(
        NS_MAIN                 => 1,
        100                     => 1,
        102                     => 1,
        104                     => 1,
        106                     => 1
);
 
# new pages in the main namespace use MediaWiki:NewArticleTemplate:
$wgNewArticleTemplates_PerNamespace = array(
        NS_MAIN                 => "MediaWiki:NewArticleTemplate",
);
 
# new pages in any other namespace defined by $wgNewArticleTemplatesNamespaces use MediaWiki:NewArticleTemplateDefault:
$wgNewArticleTemplatesDefault = "MediaWiki:NewArticleTemplateDefault";

Handling of subpages[edit | edit source]

The handling of subpages is somewhat special:

  1. A page containing a slash ('/') is only considered a subpage if the part before the first slash represents an existing article
  2. If $wgNewArticleTemplatesOnSubpages is set to true, the extensions checks for the existence of a page with the suffix "/Subpage" to the normal title of the template-page and uses it instead, if it exists.
    In the above example, a new article in the main namespace would be prefilled with MediaWiki:NewArticleTemplate, but if the new page is a subpage of an existing page, MediaWiki:NewArticleTemplate/Subpage would be used instead, if it exists.

Categories in the templates[edit | edit source]

Note that MediaWikis includeonly- and noinclude-tags are also supported in the MediaWiki-namespace.

Example[edit | edit source]

http://vowi.fsinf.at/ has the extension installed. Try creating a new page in the main namespace, the "TU Wien"-namespace and the a new subpage of a "TU Wien"-page (all pages in TU Wien).

Changelog[edit | edit source]

1.1 (rev. 187)
  • fixed a typo in the global imports
  • much refined handling of subpages
  • if the new page is a subpage and a subpage of the template named 'Subpage' exists, it is used instead
1.0
  • first version documented here

See Also[edit | edit source]

Perhaps Extension:Preloader, Extension:PreloadManager, Extension:NewArticleTemplates and Extension:Boilerplate should be merged?