Extension:UniquePageTitle

Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:GPL licensed extensions
MediaWiki extensions manual
UniquePageTitle
Release status: betaCategory:Beta status extensions
Implementation Parser function Category:Parser function extensions
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.1.0 (2024-05-01)
MediaWiki >= 1.39.0Category:Extensions with manual MediaWiki version
License GNU General Public License 2.0 or later
Download Category:Extensions in GitHub version control
Category:All extensionsCategory:Extensions not in ExtensionJson

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

  • Download, extract and place the file(s) in a directory called UniquePageTitle in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'UniquePageTitle' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

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

History

  • 2024-05-01 Version 1.1.0 Added namespace support
  • 2024-03-28 Version 1.0.0 Initial commit

See also

Category:All extensions Category:Beta status extensions Category:Extensions in GitHub version control Category:Extensions not in ExtensionJson Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:ParserFirstCallInit extensions Category:Parser function extensions