Extension:Display Title

This page is a translated version of the page Extension:Display Title and the translation is 86% complete.
Outdated translations are marked like this.
MediaWiki 拡張機能マニュアル
Display Title
リリースの状態: 安定
実装 ユーザー インターフェイス, パーサー関数
説明 リンクテキストとトークページのタイトルに表示タイトルページプロパティを使用し、オプションでオリジナルのページタイトルをサブタイトルとして表示し、表示タイトルを問い合わせるパーサ関数を提供する。
作者
最新バージョン 4.0.2 (2023-07-26)
互換性の方針 MediaWiki とともにリリースされるスナップショット。 master には後方互換性がありません。
MediaWiki 1.39+
PHP 7.4+
Composer mediawiki/display-title
ライセンス MIT ライセンス
ダウンロード
  • $wgDisplayTitleFollowRedirects
  • $wgDisplayTitleExcludes
  • $wgDisplayTitleHideSubtitle
Quarterly downloads 63 (Ranked 89th)
Display Title 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

Display Title拡張機能を使うと、ページの表示タイトルをそのページへのリンク (他のページからのリンクとそのページの自己リンクの両方) のデフォルトのリンクテキストとして使うことができます。 Display Titleも、ページの表示タイトルをそのトークページのタイトルの一部として使用します。 オプションでオリジナルのページタイトルをページ上にサブタイトルとして表示することができます。 そして、ページの表示タイトルを問い合わせるためのパーサー機能を提供します。

この拡張機能はDISPLAYTITLEマジックワードを使用してページの表示タイトルの設定をサポートするMediaWikiコアの機能を構築しています。 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. Display Title拡張機能は、その機能を提供するために page_props テーブルの displaytitle 値に問い合わせを行います。

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のDisplayTitleという名前のディレクトリ内に配置します。
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/DisplayTitle
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'DisplayTitle' );
    
  • 必要に応じて設定してください。
  •   完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

設定

構成フラグ 既定値 説明
$wgDisplayTitleHideSubtitle false falseの場合、ページのオリジナルタイトルをタイトルバーの下にサブタイトルとして表示します。
$wgDisplayTitleExcludes [ ] ページへのリンクにおいて、ページ名を表示タイトルに置き換えてはいけないページ名の配列。
$wgDisplayTitleFollowRedirects true Defines whether redirects should be followed for displaying of the title.

Display Titleの機能には厳密には必要ではありませんが、{{DISPLAYTITLE:...}}マジックワードが期待通りに機能するようにするために、以下のMediaWikiコア構成変数を設定します。

$wgAllowDisplayTitle = true; // defaults to true
$wgRestrictDisplayTitle = false; // defaults to true

編集ページと編集リンクにタイトルを表示

編集ページとそれへのリンクに表示タイトルを使用するには、あなたのwikiで次のシステムメッセージを編集してください(必要に応じてwikiのローカル言語に置き換えてください)。

システムメッセージ ページ名 旧ページの内容 新しいページの内容
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}} }}

また、Page Forms も使用する場合。

システムメッセージ ページ名 旧ページの内容 新しいページの内容
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}} }}

使用法

リンク

リンクの種類によって異なるDisplay Title拡張機能の動作を以下にまとめます。この表は、さまざまな状況に対してリンクテキストがどのようになるかを示しています。 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. ページがリダイレクトである場合 (すなわち、以下の「ページ A リダイレクトからページ B」列のページ A)、表示タイトルが設定されている場合、その表示タイトルはこの拡張機能によって無視されることに注意してください。

ソースページにはリンクが含まれています: リダイレクトでないページ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

<span id="#getdisplaytitle_parser_function">

#getdisplaytitle パーサー関数

#getdisplaytitle パーサー関数は、提供されたページの表示タイトルを取得します。 例えば:

{{#getdisplaytitle:Book:42}}

ページBook:42の表示タイトルを表示します。 現在のページの表示タイトルを取得するには、次のようにします。

{{#getdisplaytitle:{{FULLPAGENAME}}}}

Lua/Scribuntoのサポート

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(). それらを使うには、次のような内容のページModule:DisplayTitleを作ればよい。

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段階のリダイレクトに適用されます。

履歴

この拡張機能の機能は、Semantic Title拡張機能の一部として進化しています。 バージョン1.0のSemantic Titleの作者であるVan de Buggerに特別な感謝を捧げます。

Display TitleはMediaWikiのコアの機能のみに依存します; 他の拡張機能には依存しません。 Display Titleの機能はSemantic Titleからは削除され、Semantic MediaWikiプロパティまたはCargoフィールドからページの表示タイトルを設定する機能のみが残されています。 ただし、ページの表示タイトルは、Semantic Titleの機能ではなく、{{DISPLAYTITLE:...}}を使用して設定することが推奨される。 Semantic Titleは後方互換性のために維持されています。

リリースノート

Version 4.0.2
Version 4.0.1
  • Fix title handling in hooks (T342672)
  • Revert user preference to disable the extension due to a bug (T342727) and since the current approach introduces latency and risk
Version 4.0.0
  • Drop support for MediaWiki 1.38 and earlier
  • Add mw-displaytitle-subtitle class to subtitle (T205250)
  • Fix subpage subtitles for subpages more than two levels deep (T188872)
  • Fix redirect subtitle so it does not use the displaytitle (T306459)
  • Add name and description properties to composer.json (T311321)
  • Add a user preference to disable the extension (T217179)
  • Coding style and test improvements
Version 3.3
  • Do not remove fragments if not proper part of text
  • Change PersonalUrls hook to SkinTemplateNavigation::Universal hook
  • Replace deprecated WikiPage::factory/Use WikiPageFactory
Version 3.2
  • Add config option for changing redirect display ($wgDisplayTitleFollowRedirects)
  • Replace deprecated PageProps::getInstance
Version 3.1
  • Fix incompatibility with the Cite extension
Version 3.0
  • Several fixes to anchor/fragment behavior
  • Updates due to code deprecations in MediaWiki
  • Compatibility dropped with MW 1.34 and lower
Version 2.2.0
  • リンクにDisplayTitleを使用しないページのリストを定義するために$wgDisplayTitleExcludes配列を追加する
  • リンクテキストにアンダースコアが含まれる場合の挙動を修正
  • 非推奨のParserBeforeStripフックを使用しないでください。
Version 2.1.0
  • テストの追加
  • NULLタイトルチェックを追加
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
  • リダイレクトページに、ターゲットページの表示タイトルを表示する。
    • 単一レベルのリダイレクトに従う
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
  • ログイン済み利用者が「info」操作を使用した際の問題を修正
Version 1.5
  • リンクテキストをオーバーライドするはずのテキストが無視されていた。
  • ヘッダーのユーザーページへのリンク修正(個人用URL)
Version 1.4
  • MediaWiki 1.28+で動作するように更新しました。
Version 1.3
  • 自己リンクの表示テキストを非自己リンクと同様に決定するように修正
Version 1.2
  • User:Oettererによって書かれたmw.ext.displaytitle.get()、mw.ext.displaytitle.get()のLua関数を追加。
Version 1.1
  • リンク作成時にタイトルがフラグメントのみであるかどうかのチェックを追加
Version 1.0
  • 初回リリース

既知の非互換性

  • 設定パラメータ$wgDisplayTitleHideSubtitleは、バージョン1.5.0より低いSemantic Breadcrumb Links拡張機能もインストールされている場合、機能しません。 そのため、タイトルバーの下に元のページタイトルが表示されなくなります。

関連項目