手册:注脚

From MediaWiki.org
Jump to: navigation, search
This page is a translated version of the page Manual:Footer and the translation is 47% complete.

Other languages:
English • ‎polski • ‎русский • ‎中文

添加链接至注脚

MediaWiki版本: 1.17

As of 1.17 you can modify the list of links in the footer using the SkinTemplateOutputPageBeforeExec to modify the footerlinks arrays and setting new template keys for the values.

For example, putting this in your LocalSettings.php file will add a new "Terms of Use" link after the disclaimer link.

$wgHooks['SkinTemplateOutputPageBeforeExec'][] = function( $sk, &$tpl ) {
	$tpl->set( 'termsofuse', $sk->footerLink( 'termsofuse', 'termsofusepage' ) );
	$tpl->data['footerlinks']['places'][] = 'termsofuse';
	return true;
};

From there you can put "Terms of Use" in the page MediaWiki:Termsofuse on your wiki, for the link's text and in MediaWiki:Termsofusepage define the title of the page that you want the Terms of Use link to point to. Note, if you do not create these pages on your wiki, then nothing will appear in the footer.


  • It is possible to add more than one link. Just add a new call to the hook for each link required. Make sure that you change the identifiers for the function and the system messages when doing so.
  • If you are adding more than one link every link is placed in a new line within the footer. Thus you might want to adjust this for the links to appear in just one line by adding e.g. the following CSS to MediaWiki:Common.css:
li#footer-termsofuse {
    float: left;
    margin-right: 2em;
}

Another example, if you are writing an extension using MediaWiki 1.28 or later. (1) Add this to your extension.json:

	"Hooks": {
		"SkinTemplateOutputPageBeforeExec": [
			"MyExtensionHooks::onSkinTemplateOutputPageBeforeExec"
		]
	},

(2) Add this to your MyExtension.hooks.php:

	public static function onSkinTemplateOutputPageBeforeExec(&$skin, &$template) {
		$template->set('FooLabel', $skin->footerLink('FooLabel', 'FooPage'));
		$template->data['footerlinks']['places'][] = 'FooLabel';
		return true;
	}

(3) Create three pages:

  • Mediawiki:FooLabel (contains text to display in footer, like 'Foo');
  • Mediawiki:FooPage (contains namespace:title of linked page, like 'Project:Foo');
  • Project:Foo (contains detailed page text).

Remember it may take a while to update due to MediaWiki caches. In case you are using Extension:MobileFrontend, which inserts a "Mobile view" link in the footer after the disclaimer link, the new footer links will come after the "Mobile view" link. To solve this, insert the above new footer links code before the code lines used to load the MobileFrontend extension.

MediaWiki版本: 1.16

Before Mediawiki 1.17, to add or remove items from the footer on your MediaWiki page, you must edit the individual skin.

For example: if you go in to MonoBook.php (located by default in the skins folder) you will find the following code:

$footerlinks = array(
	'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
	'privacy', 'about', 'disclaimer', 'tagline',
);

In the above you can simply add and remove items from the array that you wish to appear in your footer. This must be done for each skin. It may take a while to update due to MediaWiki caches.

自定义内置项目

You can also customize the individual built-in items by modifying certain pages or parameters:

lastmod
编辑MediaWiki:Lastmodifiedat。如果启用了$wgMaxCredits的话,也请编辑MediaWiki:Lastmodifiedatby。您也可以编辑MediaWiki:othercontribs,其显示其他贡献(6518
viewcount MW 1.24 and before
numberofwatchingusers
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 
this is a link only. Edit MediaWiki:Privacy for the link text and MediaWiki:Privacypage for the wiki page to which to link.
about 
this is a link only. Edit MediaWiki:Aboutsite for the link text and MediaWiki:Aboutpage for the wiki page to which to link.
disclaimer 
this is a link only. Edit MediaWiki:Disclaimers for the link text and MediaWiki:Disclaimerpage for the wiki page to which to link.
tagline 
目前不在注脚中使用

To remove the privacy, about and/or disclaimer links entirely, replace the link text with a single dash ("-").

图片

参见$wgFooterIcons

文本和图片

目前(2016年9月以来)似乎没有办法(容易的办法?)同时添加包含文本图片的记录。这仍旧是缺失功能。

参见