Extension:UniquePageTitle

From Linux Web Expert

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


MediaWiki extensions manual
UniquePageTitle
Release status: beta
Implementation Parser function
Description Adds a number suffix to a page title if a page with the same title already exists
Author(s) Uwe Schützenmeister (Filburttalk)
Latest version 1.0.0 (2024-03-28)
MediaWiki >= 1.39.0
License GNU General Public License 2.0 or later
Download
Quarterly downloads Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').

The UniquePageTitle extension is a parser extension that adds a number suffix to a page title if a page with the same title already exists and returns this adjusted page title. The extension can be useful in combination with extensions such as VisualData or PageForms.

Installation

  • <translate> <tvar name=1>Download, extract</tvar> and place the file(s) in a directory called <tvar name=name>UniquePageTitle</tvar> in your <tvar name=ext>extensions/</tvar> folder.</translate>
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'UniquePageTitle' );
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Usage

The #uniquepagetitle parser function takes the page title as parameter

{{#uniquepagetitle:My page}}

The next highest number is always used, even if pages have been deleted previously. For this purpose, the extension checks both the page AND the archive table in the database.

Usage with Extension VisualData

The extension is particularly useful in combination with the Extension:VisualData.

Create a new field under 'properties' in your VisualData schema, i.e. 'unique pagetitle'

In 'value formula' insert

{{#uniquepagetitle:<my field>}}

where <my field> is the field the page title will be generated from

In the form call add the following:

{{#visualdataform:
...
|pagename-formula = <unique pagetitle>
...
}}

Examples

{{#uniquepagetitle|My Page}}

will become 'My Page 1' if 'My Page' already exists

{{#uniquepagetitle|My Page}}

will become 'My Page 2' if 'My Page 1' already exists

{{#uniquepagetitle|My Page}}

will become 'My Page 3' if 'My Page 1' and 'My Page 2' already exist and also if one of them has been deleted before

{{#uniquepagetitle|My Page 1}}

will become 'My Page 1 1' if 'My Page 1' already exists


See also