Extension:Display Title

From mediawiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:Display Title and the translation is 29% complete.
Other languages:
Deutsch • ‎English • ‎Türkçe • ‎français • ‎polski • ‎فارسی • ‎中文 • ‎日本語
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced.svg
Display Title
リリースの状態: 安定
実装 ユーザー インターフェイス, パーサー関数
説明 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
作者
最新バージョン 2.1.0 (2020-02-04)
互換性ポリシー master
MediaWiki 1.29+
PHP 5.5+
ライセンス MIT ライセンス
ダウンロード
  • $wgDisplayTitleExcludes
  • $wgDisplayTitleHideSubtitle
使用状況とバージョン マトリクスを確認してください。
問題点 未解決のタスク · バグを報告

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 Display Title extension queries the displaytitle value in the page_props table to provide its features.

インストール

  • ダウンロードして、ファイルを extensions/ フォルダー内の DisplayTitle という名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php の末尾に追加します:
    wfLoadExtension( 'DisplayTitle' );
    
  • Configure as required
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

Configuration parameters

Configuration Flag 既定値 説明
$wgDisplayTitleHideSubtitle false If false, display the page's original title as a subtitle below the title bar.

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

使用法

Linking

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: リダイレクトでないページA ページBへのリダイレクトであるページA
DISPLAYTITLEを持たないページA ZというDISPLAYTITLEをもつページA DISPLAYTITLEを持たないページB YというDISPLAYTITLEをもつページB
[[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パーサー関数

The #getdisplaytitle parser function gets the display title of the page provided. 例えば:

{{#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

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.

リダイレクト

リダイレクトページでは、リダイレクト先のページがDISPLAYTITLEを持っている場合、それがリダイレクトページでの表示タイトルとして使用されます

これは、ユーザーが最初にこれらを見たとき、予想されない2つの意味をもつことに注意してください。 DISPLAYTITLEをもつページがリダイレクトを残して移動されると、移動が成功したことを示すページでのリンクテキストが移動元のページと移動先ページの両方で同じになります。 また、リダイレクト先がDISPLAYTITLEを持つページSpecial:WhatLinksHereであるとき、リダイレクトページのリンクテキストがリダイレクト先のページの表示タイトルになります。

1段階のリダイレクトに適用されます。

History

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.

Display Title relies only on functionality in MediaWiki core; it does not depend on any other extension. The functionality in Display Title has been removed from Semantic Title, which now retains solely the functionality to set a page's display title from a Semantic MediaWiki property or Cargo field. However, it is recommended that a page's display title be set using {{DISPLAYTITLE:...}} rather than the functionality in Semantic Title. Semantic Title is being maintained for backward compatibility.

Release notes

Version 2.1
  • Added tests
  • Added null title check
Version 2.0.0
  • Compatibility dropped with MW 1.28 and lower
  • Bug fixes:
    • T181669: Handle integers passed as link text
    • Fixed bug introduced in version 1.5.2 that caused self links to be wrapped in HtmlArmor
Version 1.5.3
  • On redirect pages, show display title of target page
    • Follows a single level of redirect
Version 1.5.2
  • Bug fixes:
    • T180413: Use supplied link text rather than display title when link text matches page title except for case of first character
    • T180409: Undefined variable: found in "DisplayTitleHooks.php" on line 152
    • T181228: Display titles with italics show as HTML
Version 1.5.1
  • Fixed issue for logged-in users on using action "info"
Version 1.5
  • Text that should have overridden link text was being ignored
  • Fix link to user page in header (personal URLs)
Version 1.4
  • Updated to work with MediaWiki 1.28+
Version 1.3
  • Modified self-links to determine display text identically to non-self-links
Version 1.2
  • Added mw.ext.displaytitle.get() and mw.ext.displaytitle.get() Lua functions written by User:Oetterer
Version 1.1
  • Added check for title with only fragment when creating link
Version 1.0
  • Initial release

Known incompatibilities

  • Configuration parameter $wgDisplayTitleHideSubtitle will 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.

関連項目