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.0.0 (2024-03-28) |
MediaWiki | >= 1.39.0 |
License | GNU General Public License 2.0 or later |
Download | GitHub:
<translate> Note:</translate> |
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
- 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.
- Pages with script errors
- Pages with syntax highlighting errors
- Pages with broken file links
- Beta status extensions
- Extensions without an image
- Parser function extensions
- Extensions without a compatibility policy
- Extensions with manual MediaWiki version
- GPL licensed extensions
- Extensions in GitHub version control
- ParserFirstCallInit extensions
- All extensions
- Extensions not in ExtensionJson