Manual:Interface/Sidebar/zh


 * 另见：手册:移除标签页

MediaWiki:Sidebar 允许用户修改导航栏. 导航栏能提供指向 wiki 中最重要位置的链接，并为网站管理员提供一个能添加一众重要链接的地方. 例如，大多数 wiki 会链接到它们的社区讨论页和实用工具页.

Monobook 和 Vector 皮肤将导航栏与搜索栏和工具箱一起放在左上角（从右到左的语言为右上角），但是该位置可能在其他皮肤上有所不同. 此侧边栏不向移动端站点的用户显示（即由 /  生成的站点版本 ——使用  钩子实现）.



自定义侧边栏
要在 wiki 上自定义 MediaWiki:Sidebar，您首先需要使用具有“editinterface”权限的用户登录. 对于管理员，这是默认启用的.

你可以以以下两种方式之一访问到 MediaWiki:Sidebar：


 * 在你的浏览器访问 http://yourdomain/wiki/index.php?title=MediaWiki:Sidebar&action=edit.
 * 在搜索栏输入 MediaWiki:Sidebar，然后按 Enter 确认.
 * 在“Special:所有消息”页面中搜索“side”.

以下是在 MediaWiki:Sidebar 中为侧边栏添加的示例代码：


 * navigation
 * mainpage|Accueil
 * Special:RecentChanges|Recent changes
 * new heading
 * portal-url|Forums
 * https://www.mediawiki.org|MediaWiki home

本示例将产生以下侧边栏：



将导航栏拆分为新的部分
导航栏可以分成几个部分，每个部分都有自己的新标题. 这是通过添加一个星号来完成的.

每个部分的标题取自第一级列表元素（上例中的“导航”和“新标题”）. 如果此文本与接口消息的名称（MediaWiki名称空间中该标题的现有页面）相对应，则该页面的文本用作标签； 否则，标题标题按原样使用. 请注意，魔术字  不起作用，因为它没有用：MediaWiki 会在回退到缺省消息之前自动找到一条翻译来显示.

在上面的例子中， 和   是章节标题.



在侧边栏创建链接
用 2 个星号创建链接（这个叫二级列表元素）. 例如：

** 目标页面|链接文本


 * 目标页面
 * 链接目标可以是界面消息（MediaWiki 命名空间中的页面）或维基页面的名称，也可以是外部链接. 在任一情况下，链接可以是内部的、跨维基的或外部的.
 * 按以下步骤操作以确定目标：
 * 获取目标文本.
 * 如果存在具有该名称的现有或默认界面消息，请使用该消息的内容而不是目标文本.
 * 如果上一步的输出是有效的 URL（以 http:// 或其他 URL 协议 开头），则链接将指向该 URL.
 * 否则，它会将其视为 wikilink 的链接目标（链接到该页面名称或 interwiki）.
 * 如果它最终会链接到“-”，则整个条目将从侧边栏中删除. （这对于通过更改包含链接的消息来删除所有语言的条目很有用）.
 * 示例：
 * " " 使用 MediaWiki:Portal-url 的文本（其中包含“”）.
 * " " 链接到 https://www.mediawiki.org 因为这是个有效的 URL.
 * " " 链接到 [[Special:RecentChanges|Special:最近更改]]，因为没有该名称的界面消息.
 * " " 出于同样的原因，链接到 w:Foo.


 * 链接文本
 * 链接文本可以是界面消息的名称（MediaWiki 命名空间中的页面）或纯文本.
 * 如果链接文本是现有或默认界面消息的名称，则将使用该消息的内容. MediaWiki 将检查本地化版本； 例如，如果当前语言是fr（法语），并且链接文本是界面消息“forum”，则在使用“forum”之前会检查“forum/fr”.
 * 否则，链接文本按原样用作目标.
 * 请注意，链接文本不是可选的，就像在普通的 wiki 链接中一样. 如果链接文本丢失， 该项目将被忽略.


 * 示例：
 * 使用了 MediaWiki:Mainpage（内容为“”）.
 * 使用“最近更改”，因为没有名为“最近更改”的界面消息.



章节顺序（元素）
某些皮肤允许自定义某些特殊元素的顺序，比如搜索框、工具箱以及语言列表. 以标题语法的形式向 MediaWiki:Sidebar 添加 SEARCH、TOOLBOX 和 LANGUAGE 关键词，即可排放对应的元素.

但是，MonoBook 等一些皮肤不再支持定义搜索元素的位置，而是将搜索元素放置在侧边栏的第一部分之后. 在这种情况下，要将搜索元素移动到顶部，解决方法是定义一个空的前导部分. 例如：


 * empty section
 * navigation
 * mainpage|mainpage
 * Special:Recentchanges|Recent changed
 * new heading
 * portal-url|portal
 * https://www.mediawiki.org|MediaWiki home

请注意，某些皮肤可能会以不同方式显示第一部分，或者在第一部分和第二部分（如果有）之间放置一些元素.



工具提示和快捷键
A tooltip is a message which appears when a cursor is positioned over an icon, image, hyperlink, or other element in a graphical user interface.

If you add an item to the sidebar, it will have no "tooltip". But you can create a tooltip by doing the following:


 * create a wiki page named "MediaWiki:Tooltip-n-&lt;id of the item>"
 * and put the tooltip in that page.

An access key or accesskey allows a computer user to immediately jump to a specific part of a web page via the keyboard.

Accesskeys can also be created by doing the following:


 * create a wiki page named "MediaWiki:Accesskey-n-&lt;id of the item>"
 * and put the accesskey in that page.

Example:


 * uses MediaWiki:Tooltip-n-mainpage-description and MediaWiki:Accesskey-n-mainpage-description.

翻译
您可以通过编辑 MediaWiki 命名空间中的相应页面来翻译您使用的字符串.

示例：将替换名为“mainpage”的项目的字符串取自 MediaWiki:Mainpage. 要为用中文显示您的维基的用户设置/更改此文本，您可以将相应的文本放在页面 MediaWiki:Mainpage/zh 上.

这样您就可以通过 MediaWiki 界面轻松翻译这些文本.

请注意，MediaWiki 将默认使用您 wiki 的默认语言显示侧边栏页面内容. 所以，如果你的维基使用中文作为其默认语言，编辑 MediaWiki:Mainpage/zh 以便向所有未更改语言设置的用户和所有匿名用户显示修改后的侧边栏.

有关更多翻译的信息，参见.

Advanced customization
The sidebar can be fully customized by implementing JavaScript or Cascading Style Sheets, or by editing the PHP files directly. Before using these methods, note that:


 * JavaScript is fragile: it will not work for users with JavaScript disabled, and scripts frequently fail in different browsers or skins.
 * Editing the PHP files can easily cause unexpected errors, and your changes will be lost in the next update unless you manually change the new files.

Remove the Sidebar and main logo at MediaWiki:Sidebar
To completely remove the sidebar and logo:

Blank the MediaWiki:Sidebar page and save.

Then add:

This moves the main text of your wiki to the left.

Completely remove the sidebar, tabs and search bar

 * See also: Manual:Remove Tabs

Deletes the logo, and the entire sidebar:


 * 1) p-logo, .generated-sidebar, #p-lang, #p-tb { display:none; }

Deletes the search bar:


 * 1) p-search { display:none; }

Deletes the talk tab:


 * 1) ca-talk { display:none!important; }

Deletes the Page tab:


 * 1) ca-nstab-main { display:none!important; }

Force UI-messages to follow content
Some pages should sometimes follow the content language, especially for multilingual sites. This can be controlled with the setting. Each message overridden in this way must be explicitly given, for example to let the sidebar link to versions given by the content language for the main page and the portal page add the following to


 * code



用 JavaScript 添加或移除工具部分
The toolbox appears on the left under MediaWiki:Sidebar. The toolbox is a dynamic element requiring programmatic methods such as skin extensions, PHP (see  and creating a new skin) or JavaScript.

The JavaScript solution uses User:{username}/common.js / MediaWiki:Common.js, available for MediaWiki 1.9+.


 * Entire MediaWiki website: copy the script below into MediaWiki:Common.js
 * One specific user: copy the script below into Special:MyPage/common.js (or the JS page for the user's current skin, such as Special:MyPage/monobook.js).

Now simply configure which link should appear in which section. You also can remove some links if you want to.

code



 * 用法
 * has to be customized for adding or removing links in specific sections:



Restricting modifications to specific usergroups
 If you want to restrict the modification of the links to a specific user group (e.g. bureaucrat), change: to

For restricting the modifications to IPs instead of a specific user group, use

Add or remove toolbox sections (PHP)
You can add in your file LocalSettings.php the hook described on this page. With this, you can modify via MediaWiki:Sidebar the links in the toolbox panel (remove some links, change their name) and add custom links (e.g. add the "Recent changes" link there instead of the navigation panel).

Make expanding/collapsing sidebar for all users (Monobook skin only)
If you use the Monobook skin and don't want to miss the expandable menu bar from e.g. Vector skin, paste the following code into MediaWiki:Monobook.js of your wiki.

Sidebar width in Monobook skin (CSS)
You can change the width of your sidebar by adding the following CSS rules to your MediaWiki:Monobook.css note that this is an article, not a file. This changes the width to 15em, the actions position and portlet width should be an em or so less, so I've set them to 14em in this example.

Change sidebar content when logged in (PHP)
Install and configure the extension.

Parser functions in sidebar
Although it is not exactly recommended, the sidebar does support parser functions (such as ), provided the  is outside the parser function, and the parser function does not span multiple lines. For example:


 * Heading

works. However the following would not work since the parser function spans multiple lines:
 * Heading

Changes not showing up
MediaWiki aggressively caches content if possible, which often causes the navigation bar to persist after changes. Purging the cache of affected pages should correct the situation. To perform a mass-purge of all caches at once, touch the  file or truncate the   table in your database (you may have to do both).

You also need to have set to. Also, if your links don't have a  in them, they will not show up because of this line of code in Skin.php:

If you are a user or average wiki admin, you will not be able to do the advanced stuff above to get changes to show up. If purging does not work either, you can sometimes still see CSS changes right away in preview (especially when changing your personal CSS). For example; changing the sidebar width, padding, or margins. Changes can take awhile to show up after saving though. If nothing shows up after awhile you may need to contact the overall wiki, or wiki farm, sysop.

Lowercase link labels
If your links are not being capitalized as intended, try adding spaces around the bar character; for example: ** http://www.example.com/download.php?file=44555 | Download

Sections disappear or show unexpected content
If a section does not display or displays unexpected content, check that the header text isn't the name of an interface message by searching Special:AllMessages. If it is, use a different header text, or create a new interface message and use it.

For example, if you want to use "Sidebar" as header text, create the interface message "MediaWiki:Sidebar-header" containing only "Sidebar". Then, use  as header.

Sections are not displayed if there are no links of the form (e.g. when the target was forgotten).

Broken links after updating Special:Version
This will happen e.g., each time there are newer translations for your site language's sidebar items. One could add new redirect pages each time, but a better solution would be to use one's own sidebar item names instead of trying to keep track of the current MediaWiki translations.



另见

 * - Unsupported PHP modifying hacks that used to be on this page
 * - remove Mediawiki tabs
 * - Unsupported PHP modifying hacks that used to be on this page
 * - remove Mediawiki tabs
 * - remove Mediawiki tabs
 * - remove Mediawiki tabs
 * - remove Mediawiki tabs