Extension:UniquePageTitle
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.1.0 (2024-05-01) |
MediaWiki | >= 1.39.0 |
License | GNU General Public License 2.0 or later |
Download | GitHub: Note: |
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
[edit]- Download, extract and place the file(s) in a directory called
UniquePageTitle
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'UniquePageTitle' );
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Usage
[edit]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
[edit]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
[edit]{{#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
[edit]- 2024-05-01 Version 1.1.0 Added namespace support
- 2024-03-28 Version 1.0.0 Initial commit
See also
[edit]- Extension:VisualData
- Extension:PageForms - PageForms also has a similar build-in mechanism <unique number>, see: Extension:Page_Forms/Linking_to_forms (The one-step process)
- Extension:IDProvider - Provides a parser function for numeric IDs.
- Extension:IDGenerator - Provides a parser function for numeric IDs.