Jump to content

手册:页脚

From mediawiki.org
This page is a translated version of the page Manual:Footer and the translation is 76% complete.

添加链接至注脚

MediaWiki版本:
1.44

你可以在LocalSettings.php 中添加,例如:

内部链接
use MediaWiki\Html\Html;
use MediaWiki\Title\Title;
$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
    if ( $key === 'places' ) {
        $footerlinks['test'] = Html::rawElement( 'a', [
			'href' => Title::newFromText(
				$skin->msg( 'test-page' )->inContentLanguage()->text()
			)->getFullURL()
		], $skin->msg( 'test-desc' )->escaped() );
    };
};
外部链接
use MediaWiki\Html\Html;
$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
    if ( $key === 'places' ) {
        $footerlinks['test'] = Html::rawElement( 'a',
            [
                'href' => 'https://www.example.org/wiki/Project:Imprint',
                'rel' => 'noreferrer noopener' // 不必须,但出于安全原因建议
            ],
        $skin->msg( 'test-desc' )->escaped() // test-desc是一个i18n文本消息
        );
    };
};

在上述示例中,test-pagetest-desc是通过代码添加的系统消息 的键名。 在将额外页脚链接代码添加到LocalSettings.php文件后,请勿忘记分别在MediaWiki:Test-pageMediaWiki:Test-desc页面上添加所需文本。

在JavaScript中

Menus can be extended using

mw.util.addPortletLink('footer-links', 'link', 'link' )

MediaWiki 1.44.0之前版本的注意事项

在1.44.0发布之前,移动版站点默认会通过CSS隐藏所有额外链接。 你可以通过在MediaWiki:Minerva.css中添加以下规则来解决这个问题。

ul.footer-places li {
  display:inline !important;
}


添加文本至注脚

MediaWiki版本:
1.44

You can also add custom text through LocalSettings.php . Here is an example to add wikitext to the footer:

$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
    if ( $key === 'info' ) {
        $footerlinks['tagline'] = $skin->msg( 'footer-tagline' )->parse();
    }
};

This adds footer-tagline as a key for the system message to be displayed in the footer. After adding the code to LocalSettings.php, please edit the MediaWiki:Footer-tagline page to edit the newly-added footer text.

自定义内置项目

您还可以通过修改某些页面或参数自定义单个内置项目:

lastmod
编辑MediaWiki:Lastmodifiedat。如果启用了$wgMaxCredits 的话,也请编辑MediaWiki:Lastmodifiedatby。您也可以编辑MediaWiki:othercontribs,其显示其他贡献(6518
credits
  • 如果$wgMaxCredits非零,它将显示页面编辑器
  • 就是设置$wgMaxCredits = 10;或任何其他数值
copyright
edit MediaWiki:Copyright-footer (in older MediaWiki versions, MediaWiki:Copyright). The parameter $1 on that page is replaced with a link to the details of copyright for your wiki. In LocalSettings.php $wgRightsText for the link text and set either $wgRightsPage or $wgRightsUrl with the location of a wiki page or external URL.
privacy
这只是一个链接。编辑MediaWiki:Privacy来自定义链接显示的文本,编辑MediaWiki:Privacypage来自定义链接到哪个wiki页面。
about
这只是一个链接。编辑MediaWiki:Aboutsite来自定义链接显示的文本,编辑MediaWiki:Aboutpage来自定义链接到哪个wiki页面。
disclaimer
这只是一个链接。编辑MediaWiki:Disclaimers来自定义链接显示的文本,编辑MediaWiki:Disclaimerpage来自定义链接到哪个wiki页面。
tagline
目前不在注脚中使用 If you would like to add text to the footer, see #Add text to the footer.

要完全删除“隐私政策”、“关于”、“免责声明”链接,可以将链接文本替换为单破折号“-”。

图片

请参阅$wgFooterIcons

参阅

gotcha