Extension:Display Title
Release status: stable |
|
|---|---|
| Implementation | User interface, Parser function |
| Description | Uses displaytitle page property in link text and talk page title; optionally displays original page title as subtitle; and provides parser function to query displaytitle |
| Author(s) | |
| Latest version | 4.1.0 (2025-08-19) |
| Compatibility policy | Snapshots releases along with MediaWiki. Master is not backward compatible. |
| MediaWiki | 1.39+ |
| PHP | 7.4+ |
| Composer | mediawiki/display-title |
|
|
| Licence | No licence specified |
| Download | |
| Translate the Display Title extension | |
| Issues | Open tasks · Report a bug |
The Display Title extension allows a page's Display title to be used as the default link text in links to the page - both links from other pages as well as self-links on the page. Display Title also uses the display title of a page as part of the title of its talk page. It optionally displays the original page title as a subtitle on the page. And, it provides a parser function to query a page's display title.
This extension builds on functionality in MediaWiki core that supports setting a page's display title using the DISPLAYTITLE magic word.
Placing {{DISPLAYTITLE:My Display Title}} on a page stores the value of the display title (My Display Title in this case) in the displaytitle page property of the MediaWiki page_props table and, if configured appropriately, displays that value on the page as the title in the title bar.
The extension queries the displaytitle value in the page_props table to provide its features.
Installation
[edit]- Download and move the extracted
DisplayTitlefolder to yourextensions/directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/DisplayTitle
- Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'DisplayTitle' );
- Configure as required.
Done – Navigate to Special:Versionon your wiki to verify that the extension is successfully installed.
Configuration
[edit]| Configuration flag | Default value | Description |
|---|---|---|
$wgDisplayTitleHideSubtitle
|
false
|
If false, display the page's original title as a subtitle below the title bar. |
$wgDisplayTitleExcludes
|
[ ]
|
An array of names of pages that should not have their page names replaced with their display title in links to the page. |
$wgDisplayTitleFollowRedirects
|
true
|
Defines whether redirects should be followed for displaying of the title. |
While not strictly necessary for the functioning of Display Title, in order to allow the {{DISPLAYTITLE:...}} magic word to function as expected, set the following MediaWiki core configuration variables:
$wgAllowDisplayTitle = true; // defaults to true
$wgRestrictDisplayTitle = false; // defaults to true
Display title on edit pages and edit links
[edit]In order for the Display Title to be used on edit pages and links to them, edit the following system messages on your wiki (substituting the wiki's local language where appropriate):
| System Message Page Name | Old Page Content | New Page Content |
|---|---|---|
| MediaWiki:Editing | Editing $1 | Editing {{#if: {{NAMESPACE}} | {{NAMESPACE}}: |}}{{#getdisplaytitle:{{SUBJECTPAGENAME}}}} |
| MediaWiki:Editingcomment | Editing $1 (new section) | Editing {{#if: {{NAMESPACE}} | {{NAMESPACE}}: |}}{{#getdisplaytitle:{{SUBJECTPAGENAME}}}} (new section) |
| MediaWiki:Editingsection | Editing $1 (section) | Editing {{#if: {{NAMESPACE}} | {{NAMESPACE}}: |}}{{#getdisplaytitle:{{SUBJECTPAGENAME}}}} (section) |
| MediaWiki:Editsectionhint | Edit section: $1 | Edit section: {{#if: {{NAMESPACE}} | {{NAMESPACE}}: |}}{{#getdisplaytitle:{{SUBJECTPAGENAME}}}} |
| MediaWiki:Creating | Creating $1 | Creating {{#if:{{NAMESPACE}}|{{NAMESPACE}}:}} {{#getdisplaytitle: {{SUBJECTPAGENAME}} }} |
And if you also use Page Forms.
| System Message Page Name | Old Page Content | New Page Content |
|---|---|---|
| MediaWiki:Pf formedit createtitle | Create $1: $2 | Create $1: {{#if:{{NAMESPACE}}|{{NAMESPACE}}:}} {{#getdisplaytitle: {{SUBJECTPAGENAME}} }} |
| MediaWiki:Pf formedit edittitle | Edit $1: $2 | Edit $1: {{#if:{{NAMESPACE}}|{{NAMESPACE}}:}} {{#getdisplaytitle: {{SUBJECTPAGENAME}} }} |
Usage
[edit]Linking
[edit]The behavior of the Display Title extension for different types of links is summarized below. The table shows what the link text will be for different situations. In the table, A represents a page title and a represents the page title with the first character of the page name (i.e. the part after the Namespace: if there is a namespace) in lower case. Note that if a page is a redirect (i.e. Page A in the "Page A Redirects to Page B" columns below) and has a display title set, that display title will be ignored by this extension.
| Source page contains link: | Page A Does Not Redirect | Page A Redirects to Page B | ||
|---|---|---|---|---|
| Page A Does Not Have Display Title | Page A Has Display Title Z | Page B Does Not Have Display Title | Page B Has Display Title Y | |
| [[A]] | A | Z | B | Y |
| [[a]] | a | |||
| [[A | A]] | A | Z | B | Y |
| [[a | A]] | A | Z | B | Y |
| [[A | a]] | a | |||
| [[a | a]] | a | |||
| [[A | X]] | X | |||
| [[a | X]] | X | |||
#getdisplaytitle parser function
[edit]The #getdisplaytitle parser function gets the display title of the page provided.
For example:
{{#getdisplaytitle:Book:42}}
will show the displaytitle of page Book:42. To get the display title of the current page, use:
{{#getdisplaytitle:{{FULLPAGENAME}}}}
Lua/Scribunto support
[edit]Two Lua (see Extension:Scribunto) functions exist for getting and setting a page's display title: mw.ext.displaytitle.get() and mw.ext.displaytitle.set().
To use them, you could create a page Module:DisplayTitle containing the following:
local p = {}
function p.set(frame)
return mw.ext.displaytitle.set(frame.args[1])
end
function p.get(frame)
return mw.ext.displaytitle.get(frame.args[1])
end
return p
You could then use {{#invoke:DisplayTitle|set|My Display Title}} on a page to set the page's display title to My Display Title, and you could use {{#invoke:DisplayTitle|get|My Page}} to get the display title of page My Page.
Redirects
[edit]For redirect pages, if the target page has a display title, it will be used as the display title of the redirect page.
Note that this has two implications that may be unexpected the first time a user sees them. When a page with a display title is moved leaving a redirect, on the page indicating that the move was a success the link text will be the same for both the source and target pages. And, on the Special:WhatLinksHere page for a page with a display title that is the target of a redirect, the link text of the redirect page will be the display title of the target page.
A single level of redirect will be followed.
History
[edit]The functionality in this extension evolved as part of the Semantic Title extension. Special thanks go to Van de Bugger, the author of version 1.0 of Semantic Title.
Release notes
[edit]| Version | Description |
|---|---|
| 4.1.0 | Bug fixes |
| 4.0.3 | Bug fixes |
| 4.0.2 | Fix Lua class name (T343929) |
| 4.0.1 | |
| 4.0.0 |
|
| 3.3 |
|
| 3.2 |
|
| 3.1 | Fix incompatibility with the Cite extension |
| 3.0 |
|
| 2.2.0 |
|
| 2.1.0 |
|
| 2.0.0 |
|
| 1.5.3 |
|
| 1.5.2 | |
| 1.5.1 | Fixed issue for logged-in users on using action "info" |
| 1.5 |
|
| 1.4 | Updated to work with MediaWiki 1.28+ |
| 1.3 | Modified self-links to determine display text identically to non-self-links |
| 1.2 | Added mw.ext.displaytitle.get() and mw.ext.displaytitle.get() Lua functions written by User:Oetterer |
| 1.1 | Added check for title with only fragment when creating link |
| 1.0 | Initial release |
Known incompatibilities
[edit]- Configuration parameter
$wgDisplayTitleHideSubtitlewill not work if you also have the Semantic Breadcrumb Links extension lower than version 1.5.0 installed. Thus the original page title will not display below the title bar.
See also
[edit]| This extension is included in the following wiki farms/hosts and/or packages: |
- Stable extensions
- User interface extensions
- Parser function extensions
- Extensions supporting Composer
- BeforePageDisplay extensions
- HtmlPageLinkRendererBegin extensions
- OutputPageParserOutput extensions
- ParserFirstCallInit extensions
- ScribuntoExternalLibraries extensions
- SelfLinkBegin extensions
- SkinTemplateNavigation::Universal extensions
- MIT licensed extensions
- Extensions in Wikimedia version control
- All extensions
- Extensions included in Canasta
- Extensions included in Miraheze
- Extensions included in MyWikis
- Extensions included in ProWiki
- Extensions included in semantic::core
- Extensions included in wiki.gg
- Extensions by MITRE
