Extension:Semantic Title

From MediaWiki.org
(Redirected from Extension:SemanticTitle)
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Semantic Title
Release status: stable
Implementation User interface
Description Sets visible page title to value of a page's SemanticMediaWiki property or Cargo field.
Author(s) Cindy Cicalese,Van de Bugger
Latest version 4.0 (2016-11-28)
Compatibility policy master
MediaWiki 1.25+
PHP 5.3+
Database changes No
License MIT License
Download
Example sandbox.semantic-mediawiki.org
Parameters
  • $wgSemanticTitleProperties
  • $wgSemanticTitleCargoFields
Hooks used
ParserBeforeStrip
Translate the Semantic Title extension if it is available at translatewiki.net
Check usage and version matrix.
Issues Open tasks · Report a bug

The Semantic Title extension allows an alternate display title to be displayed on the title bar of a page. The display title can be set with a semantic property or Cargo field. The value of the display title is stored in the displaytitle property of the MediaWiki page_props table (Manual:page_props table).

For example, if page 'Bug:32758' has semantic property 'Title' with value 'Timezones handled incorrectly', and Semantic Title is properly installed and configured, the visible page title will be 'Timezones handled incorrectly', with subtitle 'Bug:32758'.

Note Note: As of version 4.0 of this extension, the following features have been moved to the Display Title extension: use the displaytitle page property in link text and talk page title; optionally display original page title as subtitle; and provide parser function to query displaytitle.

Rationale[edit]

Let us assume we are creating a bug tracking system based on MediaWiki. Semantic MediaWiki converts wiki into a database. Pages become objects or entities (e. g. bugs) with properties (e. g. title, submitter, severity, component, etc). We want every bug to be identified by its number, assigned automatically. Semantic Forms allows it:

{{{info|page name=Bug:<unique number>}}}
{{{for template|Bug|...}}}
...

so every new bug receives unique identifier. Everything works, but bug page title will be `Bug:32758', while we want to see bug titles (set by user, not an id assigned by system) in page titles. This is the job for Semantic Title extension. To update the text in links, see the Display Title extension.

Installation[edit]

Note Note: If you are using semantic properties to set the display title, this extension requires Semantic MediaWiki to be installed first. If you are using Cargo fields to set the display title, this extension requires Cargo to be installed first.

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

Note Note: If you are upgrading to Version 3.0 or higher of this extension, you will need to run the refreshLinks.php and runJobs.php maintenance scripts to correctly set the displaytitle property for all of the pages in your wiki.

Note Note: If this extension is used with the HidePrefix extension, Semantic Title should be included before HidePrefix (Semantic Title does not touch title if it was set to non-default value, e. g. processed by HidePrefix extension).

Configuration[edit]

Enable changes to page title[edit]

Set the following MediaWiki core configuration variables:

$wgAllowDisplayTitle = true;
$wgRestrictDisplayTitle = false;

Use a semantic property as display title[edit]

To set the display title using a semantic property:

$wgSemanticTitleProperties = array( 
    NS_NAMESPACE_1 => "Property name1",
    NS_NAMESPACE_2 => "Property name2",
    ...
);

where:

  • NS_NAMESPACE_XNamespace constants, e.g. NS_MAIN, NS_USER, or a user-defined namespace. Only pages in specified namespaces are affected. You can use the integer index of the namespace or the associated namespace constant. Do not use the string name of the namespace.
  • Property name# — Name of property of data type text to be used as title in the specified namespace. It is important that the data type of the property is of type text so you need to manually create the respective property on the wiki (or use the special page Special:CreateProperty when Semantic Forms is installed.)

Use a Cargo field as display title[edit]

To set the display title using a Cargo field:

$wgSemanticTitleCargoFields = array( 
    NS_NAMESPACE_1 => array( 'table' => 'table1', 'field' => 'namefield1' ),
    NS_NAMESPACE_2 => array( 'table' => 'table2', 'field' => 'namefield2' ),
    ...
);

Usage[edit]

Being installed and configured, Semantic Title handles page titles with no user intervention.

However, category listings may look ugly, because listings show semantic titles while pages are sorted in order of their actual titles. Use {{DEFAULTSORT: }} magic word to fix it, e. g.:

[[Has title::title]]
{{DEFAULTSORT: title }}

Release Notes[edit]

Version 4.0
  • The following features have been moved to the Display Title extension: use the displaytitle page property in link text and talk page title; optionally display original page title as subtitle; and provide parser function to query displaytitle.
Version 3.2
  • This version provides a bug fix which prevents setting link texts to empty strings.
Version 3.1
  • This version fixed a bug if non-existant pages are involved.
Version 3.0
  • This version is a significant reimplementation of the functionality. It now uses the MediaWiki built-in page_props table to be consistent with the implementation of the {{DISPLAYTITLE: }} magic word. Consequently, Semantic Title will now work with display titles set with that magic word.
  • Added support for display titles set with Cargo fields.
  • Removed Semantic Title API as it is no longer necessary. The display title can be queried using the MediaWiki API (action=query&prop=pageprops ...)
Version 2.1
  • Added SemanticTitle:getText() and API interface.
Version 2.0
  • Talk pages that have a semantic title for the associated subject page have their titles displayed with that semantic title. The display of the talk page title can be customized with the message "semantictitle-talkpagetitle".
  • Fixed character encoding bug.
  • Coding style modifications.
Version 1.3
  • Fixed bug that caused the page title not to be transformed on pages that use the LiquidThreads extension. This may also have affected other pages with title fragments.
Version 1.2
  • Added support for the SelfLinkBegin hook (Linker.php in MediaWiki core). This replaces self links on a page with the semantic title text as the link text.
Version 1.1.0
  • Remediated XSS vulnerability CVE-2014-2854.
  • Migrated to JSON i18n. Beginning with MediaWiki 1.23, translation strings are stored in JSON files, and the EXTENSION.i18n.php file only exists to provide compatibility with older releases of MediaWiki. For more information about this migration, see: https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format.

Caveats[edit]

  • Semantic Title overrides edit page title set by Semantic Forms (specified by `{{{info ...|edit title=...}}}' construct).
  • Sometimes when saving a page with a new property/field value being used as the page title, the new title will not immediately appear. If this occurs, save the page again or try purging the page.
  • The display title of a page can now be set with the DISPLAYTITLE magic word, functionality that is built into MediaWiki core, rendering this extension unnecessary in most cases. It is recommended that users of this extension transition to using DISPLAYTITLE to set the display title, if possible.

See also[edit]