Jump to content

手册:编辑章节

From mediawiki.org
This page is a translated version of the page Manual:Section editing and the translation is 22% complete.
Outdated translations are marked like this.

章节编辑是通过单击副标题旁边的“编辑”(或“编辑源代码”)链接来编辑页面上特定部分的做法。

This page is for the technical details of section editing and how to configure it. See 帮助:章节 for the end-user documentation about the feature.

Existing sections

When editing a section in the source editor, the URL contains section=n where n is an integer index to the section being edited. These are counted from 0 (but see #Lead section below for more about section 0). If you try to edit a section number that doesn't exist, you'll get an error message.

When editing a section, the edit summary field is pre-populated with a special section indicator, such as /* Existing sections */, which will be turned into a link when it's viewed in page history, diffs, etc.

When opening a section for editing in the VisualEditor , the whole page is opened for editing. The main difference between this and editing the whole page is that the edit summary is still pre-populated with the section name.

New sections

It is possible to create a new section at the end of a page by adding section=new to the URL. This opens the normal editing form, with an additional text field above the page textbox (labelled 'Subject:'), into which the section title can be entered.

In addition, the normal edit summary field is hidden. It's not possible to add an edit summary when adding a new section, because the section title will be used (in fact, the 'Subject:' and 'Summary (?):' fields are internally the same). The phrase 'New section' will be added to the generated edited summary.

If the DiscussionTools extension is installed, adding a new section will not open the page editing form but instead direct you to a new comment form at the bottom of the page.

Lead section

Page content that is before the beginning of the first section is called the "lead section" or "section zero". It can not be edited directly via the UI in most skins, but it is possible to manually change the edit URL to include section=0. Various Gadgets exist to make this easier, such as the edittop gadget.

Right-click to edit

The 启用通过右击章节标题编辑章节 user preference (editsectiononrightclick, "0" by default) allows users to edit a section by right-clicking on the section heading. This feature requires JavaScript to be enabled.

限制

启用和禁用章节链接

章节编辑是 MediaWiki 的默认功能,但可以通过以下多种方式禁用。 隐藏章节标题旁的编辑链接。当从模板中创建标题时,正常的页面章节编辑将编辑模板代码,这与用户的直觉不符。

Historical note: In MediaWiki 1.23 and earlier there was a user preference for disabling the section editing links. This was removed with T54811.

Site or user stylesheets

It is possible to use the global or personal stylesheets to remove the section editing links. The following CSS shoulg be added to MediaWiki:Common.css or Special:MyPage/common.css:

.mw-editsection {
    display:none !important;
}

魔术字

The Magic word __NOEDITSECTION__ can be used to hide all section edit links on a particular page.

This magic word is transcludable, meaning that it can be embedded in a template in order to disable section editing on all pages where this template is used.

CSS

In Vector and other skins, the section link has the following CSS class:

.mw-editsection