手册:页脚
添加链接至注脚
MediaWiki版本: | ≥ 1.35 |
In MediaWiki 1.35, links can be added or overridden via the SkinAddFooterLinks hook. (See Manual:Footer/legacy for older installs.) For example, in an extension:
- 内部链接
// Add a link to the page "Test Page" with the text "Test", allowing modification by wiki administrators
// test-desc and test-page are i18n messages with the text of the link and the name of the page, respectively
public static function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerlinks ) {
if ( $key === 'places' ) {
$footerlinks['test'] = $skin->footerLink( 'test-desc', 'test-page' );
}
}
The two parameters passed to the skin::footerlink
function should be i18n message keys. This means the eventual value will be taken from the content of the MediaWiki namespace page corresponding to those message keys; in this case the contents of the pages MediaWiki:test-desc and MediaWiki:test-page.
The first parameter should contain the link text, the second the name of the page to link to. See the Class level documentation for more details.
- 外部链接
// Add a link to this page (https://www.mediawiki.org/wiki/?curid=6031)
// test-desc is an i18n message of the text
public static function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerlinks ) {
if ( $key === 'places' ) {
$footerlinks['test'] = Html::element( 'a',
[
'href' => 'https://www.mediawiki.org/wiki/?curid=6031',
'rel' => 'noreferrer noopener' // not required, but recommended for security reasons
],
$skin->msg( 'test-desc' )->text()
}
}
或者你一名是站点管理员,希望在LocalSettings.php 中添加它:
- ; 内部链接
MediaWiki版本: | ≥ 1.35 |
$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
if ( $key === 'places' ) {
$footerlinks['test'] = Html::element( 'a', [
'href' => Title::newFromText(
$skin->msg( 'test-page' )->inContentLanguage()->text()
)
], $skin->msg( 'test-desc' ) );
};
};
- 外部链接
// Add a link to this page (https://www.mediawiki.org/wiki/?curid=6031)
// test-desc is an i18n message of the text
$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
if ( $key === 'places' ) {
$footerlinks['test'] = Html::element( 'a',
[
'href' => 'https://www.mediawiki.org/wiki/?curid=6031',
'rel' => 'noreferrer noopener' // not required, but recommended for security reasons
],
$skin->msg( 'test-desc' )->text()
);
};
};
自定义内置项目
您还可以通过修改某些页面或参数自定义单个内置项目:
lastmod
- 编辑MediaWiki:Lastmodifiedat。如果启用了$wgMaxCredits 的话,也请编辑MediaWiki:Lastmodifiedatby。您也可以编辑MediaWiki:othercontribs,其显示其他贡献(6518)
credits
-
- 如果$wgMaxCredits非零,它将显示页面编辑器
- 就是设置
$wgMaxCredits = 10;
或任何其他数值
copyright
- edit 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
- 目前不在注脚中使用
要完全删除“隐私政策”、“关于”、“免责声明”链接,可以将链接文本替换为单破折号“-
”。
图片
- 参见$wgFooterIcons 。
文本和图片
自2016年9月以来似乎没有標準的方法同时添加包含文本和图片的记录。