Guide ZH Hans
Guide ZH Hans
This guide was written mainly for people with minimal knowledge of the Drupal content management
system. The topics will help them become skilled at installing, administering, site building, and/or maintaining
the content of a Drupal-based website. The guide is also aimed at people who already have some experience
with a current or past version of Drupal, and want to expand the range of their skills and knowledge or update
them to the current version.
i
Contents
前言 vii
Copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Audience and Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
Reporting Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
Conventions of the Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Guiding Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
1 理解 Drupal 1
1.1 概念:Drupal 作为一个内容管理系统 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 概念:模块 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 概念:主题 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Concept: Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Concept: Types of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.6 概念:Drupal 项目 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.7 Concept: Drupal Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 规划您的站点 7
2.1 Concept: Regions in a Theme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Planning Your Site Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Concept: Content Entities and Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Concept: Modular Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.5 Planning your Content Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.6 Concept: Editorial Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3 安装 15
3.1 概念:服务器要求 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2 Concept: Additional Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.3 Preparing to Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4 Running the Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4 基本站点配置 27
4.1 Concept: Administrative Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 Editing Basic Site Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3 Installing a Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.4 Uninstalling Unused Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.5 Configuring User Account Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.6 Configuring the Theme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5 基本页面管理 43
5.1 Concept: Paths, Aliases, and URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2 Creating a Content Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3 Editing a Content Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.4 Editing with the In-Place Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.5 Designating a Front Page for your Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.6 Concept: Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.7 Adding a Page to the Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.8 Changing the Order of Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
iii
CONTENTS
6 内容结构 57
6.1 Adding a Content Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
6.2 Deleting a Content Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.3 Adding Basic Fields to a Content Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.4 Concept: Reference Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.5 Concept: Taxonomy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.6 Setting Up a Taxonomy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.7 Adding a Reference Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.8 Concept: Forms and Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.9 Changing Content Entry Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.10 Concept: View Modes and Formatters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.11 Changing Content Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.12 Concept: Image Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.13 Setting Up an Image Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.14 Concept: Responsive Image Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
6.15 Concept: Text Formats and Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
6.16 Configuring Text Formats and Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7 管理用户账号 99
7.1 概念:用户,角色和权限 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
7.2 Concept: The User 1 Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.3 Creating a Role . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.4 Creating a User Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
7.5 Assigning Permissions to a Role . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
7.6 Changing a User’s Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
7.7 Assigning Authors to Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
8 区块 113
8.1 Concept: Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
8.2 Creating A Custom Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
8.3 Placing a Block in a Region . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
9 用视图创建列表 119
9.1 Concept: Uses of Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
9.2 概念:视图的组成 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
9.3 Creating a Content List View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.4 Duplicating a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.5 Adding a Block Display to a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
10 多语言 135
10.1 Concept: User Interface, Configuration, and Content translation . . . . . . . . . . . . . . . . . . 135
10.2 Adding a Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
10.3 Configuring Content Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
10.4 Translating Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
10.5 Translating Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
11 扩展和自定义网站 145
11.1 Finding Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
11.2 Enabling and Disabling Maintenance Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
11.3 Downloading and Installing a Module from Drupal.org . . . . . . . . . . . . . . . . . . . . . . . . 152
11.4 Finding Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
11.5 Downloading and Installing a Theme from Drupal.org . . . . . . . . . . . . . . . . . . . . . . . . 157
11.6 Manually Downloading Module or Theme Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
11.7 Concept: Development Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
11.8 Making a Development Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
11.9 Using Composer and Git to Download Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
iv
CONTENTS
12 防止和修复问题 173
12.1 Concept: Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
12.2 Clearing the Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
12.3 Concept: Data Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
12.4 Concept: Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
12.5 Concept: Status Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
13 安全和维护 179
13.1 Concept: Cron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
13.2 Configuring Cron Maintenance Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
13.3 Concept: Security and Regular Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
13.4 Keeping Track of Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
13.5 Updating the Core Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
13.6 Updating a Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
13.7 Updating a Theme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
14 结语 189
14.1 Connecting with the Community . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
14.2 Getting Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
14.3 Learning More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
15 词汇表 193
A Appendix 199
A.1 Guide-Wide Attributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Index 201
v
前言
Copyright
This guide was written by contributors to the Drupal open-source project. It is copyright 2015-2017 by the
individual contributors, and can be used in accordance with the Creative Commons License, Attribution-
ShareAlike 2.0 (CC BY-SA 2.0). Each page in this document (including this one) has an Attributions statement
at the bottom, listing the people who contributed to writing and editing that page. See also Section A.1,
“Guide-Wide Attributions”for guide-wide editing, translating, and project management information.
The CC BY-SA license (very similar to the GPL) allows anyone to copy, modify, and redistribute modifica-
tions of all or part of this work, as long as the following is complied with:
• You provide appropriate credit (see the license for more information).
• You provide a link to the license.
vii
前言 ORGANIZATION
• Understand documentation and blog posts on topics not covered here, to expand your knowledge and
skills
Organization
This user guide contains a series of topics, each of which covers either a task (how to do something) or a concept
(background knowledge, terminology, and the like). Concept topics have names starting with Concept:, while
task topics have names containing verbs, like Editing Basic Site Information.
The topics are grouped into chapters in a logical order, with concepts and tasks interleaved so that concepts
are presented before related tasks, and tasks build on each other. To take advantage of this, you are encouraged
to read the entire guide in its presented order, possibly skipping topics that are not of interest or that present
information you already know. Remember to try out the tasks on your own site as you read the guide; most
people learn better by doing rather than reading.
If you prefer, you can also use the index or table of contents to jump straight to a topic that you’d like to
learn about, rather than reading the entire guide. To facilitate this approach, each topic lists the prerequisite
knowledge that you’d need in order to understand it, if any (with links to the topics that present that
knowledge); task topics also list site prerequisites (things that you would need to have configured or created on
your site in order to perform the task). Also, most topics have sections at the end where you can find related
information and/or tasks for expanded understanding, to continue your learning.
You may also want to refer to the 词汇表 section as you read — it gives brief definitions of most of the
terminology used in the guide, with links to topics having more detailed explanations.
Attributions
Written by Jennifer Hodgdon.
Reporting Problems
Goal
Report a problem with this guide, such as:
• Information that is incorrect or does not follow best practices
• Steps that do not work
• Screen shots or text that doesn’t match what you see on the screen
• Unclear writing
• Places where a table or screen shot would help clarify the text
• Failure to define terminology
viii
前言 CONVENTIONS OF THE GUIDE
Steps
1. Make a note of the topic or topics that contain the problem you have found.
2. Log in to Drupal.org (you will need to create a user account if you do not already have one).
3. Visit the User Guide issues page on Drupal.org.
4. Verify that the problem you found has not already been reported in another issue:
• If there are only a few open issues, scan the Summary column to see if any of their descriptions match
the problem you found. You may also need to read some of the issues to make sure, which you can
do by clicking the links in the Summary column.
• If the open issue list is long, enter either a keyword related to the problem you found or the title of
the topic where the problem occurs in the Search for box, and click Search to reduce the issue list.
Then either scan the summaries or read the issues to see if they match your problem.
5. If you determine that your problem has not already been reported, click Create a new issue, and fill in
the issue report as follows:
6. Reread the Title and Issue summary you entered, and verify that the following information is included in
your report:
Attributions
Written by Jennifer Hodgdon.
ix
前言 CONVENTIONS OF THE GUIDE
• Many task topics list Site prerequisites, which are tasks that you’ll need to have completed on your site
before you’ll be able to do the task in the topic you are reading.
• The specifics of the site prerequisites relate to the scenario used throughout this guide of building a site
for a farmers market (see the section called “Guiding Scenario”for details). You can adapt the tasks to
your own scenario, but you will also need to remember the changes you made when deciding if your site
satisfies the site prerequisites for a task.
• For all task topics after Section 3.4, “Running the Installer”, there is also an implicit prerequisite: you
must have installed the content management software on your site, and be logged in to a user account
with sufficient permissions to do the task (such as the user account created when you installed your site,
which automatically has full permissions).
• If you read all the topics in order, and perform all of the steps in the task topics as you go (staying logged
in), you should have the background knowledge and site prerequisites in place for each topic as you read
it.
Text conventions
The following conventions are used in the text of this guide:
• The URL example.com means the base URL of your website. See the Navigation section below for more
details on how URLs internal to your site are indicated.
• Text you should see in the user interface of your site is shown in italics, such as: Click Save configuration.
This only applies to text in the user interface that comes from the software, not to text that was entered
in a previous topic. For example, in a topic about editing, you might see this instruction: Click Edit in
the row of the About page (Edit would be in italics, but About would not be, because the About page
was created in a previous topic).
• URLs, file names, and newly-introduced terminology are also shown in italics.
• Text that you should type at a shell command line is shown in monospace type, such as:
drush cr
• Within this guide, the word directory is always used to refer to file directories (which some people prefer
to call folders).
Navigation
To do most of the task topics in this guide, you will need to navigate to one or more pages in the administrative
interface of your site. You might see something like this in the instructions (this will make more sense after you
have the base software installed):
In the Manage administrative menu, navigate to Structure > Taxonomy (admin/structure/taxonomy).
Navigation instructions like this assume that you have the core Toolbar module installed, and this ex-
ample means that in the menu bar at the top of your site, you would need to click Manage to expose the
menu choices, then click Structure, then Taxonomy, and that at the end, you would be on a page with URL
http://example.com/admin/structure/taxonomy (if your site base URL is http://example.com).
x
前言 GUIDING SCENARIO
One other note: if you are using the standard administrative core Seven theme, many ”Add” buttons in
the administrative interface are displayed with + signs on them. For instance, on admin/content, the Add new
content button appears as + Add new content. However, this is theme-dependent and is not really part of the
text on the button (for instance, it would not necessarily be read by a screen reader), so in this guide, the
convention is to not mention the + sign on the buttons.
Filling in forms
Many of the task topics in this guide include steps where you will fill out a web form. In most cases, a screen
capture image of the form will be included, along with a table of the values you will need to enter into each form
field. For example, you might see a table that starts out like this, explaining the site information form you would
see if you navigated to Configuration > System > Site information (admin/config/system/site-information):
To use this table, find the field labeled Site name in the form, and enter the name of your site in this field.
An example site name of ”Anytown Farmers Market” is suggested in the table, which relates to the scenario of
building a website for a farmers market that you’ll find all through this guide (see the section called “Guiding
Scenario”for details).
Attributions
Written/edited by Jennifer Hodgdon.
Guiding Scenario
When reading this guide, it is helpful to have a website building project in mind. The following project scenario
provides context and links together the examples in this guide:
You are making a website for a farmers market. The site needs to display information about the location
and hours of the market, and an About page with the history of the market. It also needs to list the vendors.
Vendors should be able to edit their listings (including a logo or photo), and post recipes. Site visitors should
be able to browse recipes, or locate recipes using ingredients that they purchased at the market. Some visitors
to your site speak another language, so the main pages and vendor pages need to be translated.
Attributions
Written/edited by Jennifer Hodgdon.
xi
Chapter 1
理解 Drupal
什么是 Drupal?
Drupal 是一个灵活的,基于 LAMP 技术栈的 CMS,它的模块化设计,允许通过安装和卸载模块的方式添加
和移除功能,同时,允许通过安装和卸载主题改变整个网站的视觉感观。我们平时下载的 Dr。下载更多模块和
主题,请访问 Drupal 官网。
Drupal 还可以运行在其他技术栈上:
• 除了 Linux,操作系统还可以是 Windows 或 Mac OS。
• Web 服务器可以用 Nginx 或 IIS,替代 Apache。
• 数据库可以用 PostgreSQL 或 SQLite,替代 MySQL,或者其他兼容 MySQL 的数据库比如 MariaDB 或
Percona。
其他的操作系统,Web 服务器,数据库也可以让它工作。但是,编写它的 PHP 脚本语言,这一点是不变
的。
使用 Drupal 的理由有哪些?
当创建一个网站时,您可以从众多的 CMS 和托管服务中选择,也可以选择开发您自己的 CMS 或者完全不用
CMS。而以下可能是您选择使用 Drupal 的理由:
• 创建一个短小的、简单的静态 HTML 页面并不难,很快,您就可以让一个简单的站点运行起来。而使用
CMS 构建一个网站,开始时通常需要更多时间,但是会带给你一些好处:在线编辑(这对于缺乏经验的
内容维护者很有用),统一管理(对于大型站点使用静态 HTML 是极难维护的),可以构建需要数据库支
持的复杂功能。
• 有的 CMS 仅适合特定用途;比如,您可以使用某些 CMS 和托管服务,来构建博客或俱乐部会员网站。
然而,Drupal 是一个通用的 CMS。如果您正在构建特定用途的网站,您可以选择使用特定用途的 CMS;
但是,如果您的网站会超出那怕一点点预期目的,可能最好选择通用 CMS,而不是专用 CMS。
1
CHAPTER 1. 理解 DRUPAL 1.2. 概念:模块
相关话题
• Section 1.2, “概念:模块”
• Section 1.3, “概念:主题”
相关资料
• Drupal 概述
• Drupal 官网:FAQ(常见问题)
• Drupal 官网:案例研究
• 维基百科:内容管理系统
• 维基百科:模块化设计
贡献者
编写:Kristof van Tomme @ Pronovix,Jennifer Hodgdon、Michael Lenahan @ erdfisch
翻译:冉强军 @ InterGreat Education Group
1.2 概念:模块
预备知识
Section 1.1, “概念:Drupal 作为一个内容管理系统”
什么是模块?
模块通常包含 PHP、JavaScript 以及 CSS 等文件,用于扩展站点,添加功能特性。安装操作用于启用模块,
卸载操作用于卸载模块。提醒一下,在卸载之前,可能需要移除相关数据和配置。对于每个已安装模块,它会
增加网站页面生成所需时间,所以不需要的模块,最好把它卸载。
Drupal 核心模块,提供的功能有,比如:
• 管理用户账号(User 核心模块)
• 管理基本内容(Node 核心模块)和字段(Field 和 Field UI 核心模块;也有核心模块提供字段类型)
• 管理导航菜单(Menu UI 核心模块)
2
CHAPTER 1. 理解 DRUPAL 1.3. 概念:主题
相关话题
• Section 1.3, “概念:主题”
• Section 1.4, “Concept: Distributions”
• Section 4.4, “Uninstalling Unused Modules”
• Section 11.1, “Finding Modules”
相关资料
Drupal 官网文档:模块开发者指南
贡献者
编写:Jennifer Hodgdon
翻译:冉强军 @ InterGreat Education Group
1.3 概念:主题
预备知识
Section 1.1, “概念:Drupal 作为一个内容管理系统”
什么是主题?
主题是定义站点视觉感观的一系列文件。Drupal 核心和模块决定您的站点显示什么内容(内容包括 HTML 文
本和其他存储在数据库里的数据、上传的图像以及其他资源文件)。主题则决定这些内容的 HTML 标记和 CSS
样式。
Drupal 有提供几个基本主题。这些主题是由社区在过去几年设计和开发的。对于创建第一个网站和熟悉
Drupal 核心如何工作,它们都是不错的选择。
Drupal 是一个成熟的内容管理系统,一般来说,提供(免费或付费)主题的第三方也都值得信赖。
如果第三方提供的主题不能满足您的需求,那么,您需要创建一个自定义主题。一个简单的自定义主题,
可以是单个 CSS 文件,给 Drupal 核心提供的标记添加一些样式。关于如何创建自定义 Drupal 8 主题,请访
问 Drupal 官网文档”Theming Drupal”
相关话题
• Section 11.4, “Finding Themes”
• Section 11.5, “Downloading and Installing a Theme from Drupal.org”
• Section 1.2, “概念:模块”
相关资料
https://www.drupal.org/theme-guide/8 [Drupal 官网文档”Drupal Theming”]
贡献者
编写:John Grubb、Jennifer Hodgdon
翻译:冉强军 @ InterGreat Education Group
3
CHAPTER 1. 理解 DRUPAL 1.4. CONCEPT: DISTRIBUTIONS
Related topics
Section 14.1, “Connecting with the Community”
Additional resources
Drupal.org Drupal Distribution Downloads
Attributions
Adapted and edited by Diána Lakatos and Antje Lorch, from ”Distributions” and ”Download & Extend —
Distributions” copyright 2000-2017 by the individual contributors to the Drupal Community Documentation.
Session Information about individual site visitors’ interactions with the site, such as whether they are logged
in and their cookies. This is technically a subtype of State information, since it is also temporary.
4
CHAPTER 1. 理解 DRUPAL 1.6. 概念:DRUPAL 项目
Related topics
• Section 2.3, “Concept: Content Entities and Fields”
• Section 13.1, “Concept: Cron”
• Section 7.1, “概念:用户,角色和权限”
• Section 10.1, “Concept: User Interface, Configuration, and Content translation”
Attributions
Adapted by Jennifer Hodgdon from ”Overview of Configuration (vs. other types of information)”, copyright
2000-2017 by the individual contributors to the Drupal Community Documentation
1.6 概念:Drupal 项目
预备知识
Section 1.1, “概念:Drupal 作为一个内容管理系统”
什么是自由及开放源代码软件?
自由和开源软件(FOSS)是由一种由社区的人共同开发,以非商业许可进行发布,其源代码(组成软件的程
序文件)可以免费获取的软件。关于 Drupal 使用的非商业许可证的更多信息,请查看 Section 1.7, “Concept:
Drupal Licensing”。
相关话题
• Section 1.7, “Concept: Drupal Licensing”
• Section 13.3, “Concept: Security and Regular Updates”
• Section 14.1, “Connecting with the Community”
• Section 14.2, “Getting Support”
5
CHAPTER 1. 理解 DRUPAL 1.7. CONCEPT: DRUPAL LICENSING
相关资料
• Drupal 项目管理
• Drupal 行为准则
贡献者
写作:Jennifer Hodgdon
翻译:冉强军 @ InterGreat Education Group
Related topics
Section 14.1, “Connecting with the Community”
Additional resources
• Drupal.org page on ”Licensing”
Attributions
Adapted by Diána Lakatos at Pronovix from ”Licensing” copyright 2000-2017 by the individual contributors
to the Drupal Community Documentation.
6
Chapter 2
规划您的站点
What is a region?
Besides its primary content, a web page contains other content such as site branding (site name, slogan, and
logo), navigation aids (menus, links, and icons), formatted text, and images. Each theme provides a set of
named regions, such as Header, Content, and Sidebar, where site builders may choose to place their content.
The available regions depend on the theme design. Only the Content region, which contains the primary
content, is required; others are optional. The core Bartik theme provides the eighteen regions highlighted in
the following image.
7
CHAPTER 2. 规划您的站点 2.2. PLANNING YOUR SITE LAYOUT
Related topics
• Section 8.1, “Concept: Blocks”
• Section 2.3, “Concept: Content Entities and Fields”
• Section 8.3, “Placing a Block in a Region”
Additional resources
• Drupal.org community documentation page ”Assigning content to regions”
Attributions
Written and edited by John MacDonald, and Michael Lenahan at erdfisch.
Prerequisite knowledge
• Section 1.3, “概念:主题”
• Section 2.1, “Concept: Regions in a Theme”
• the section called “Guiding Scenario”
Steps
It is a good idea to plan the site layout before you start building the site and writing content; however, your
plan may need to be revised either before you start implementing it or after you have some of the site built
with draft content in place, based on budgetary concerns or stakeholder feedback.
1. Make a list of the information that your site should present to visitors. In the farmers market scenario,
this might include:
2. Decide which information should be on which pages or types of pages on the site:
Information that should be on all pages Address, hours, and recently-added recipes list
Vendor details pages Information about each vendor on its own page
Recipe details pages Details of each recipe on its own page
Home page Location, map, directions, and hours
About page History of the market
Vendors list page List of vendors, with links to vendor detail pages
8
CHAPTER 2. 规划您的站点 2.3. CONCEPT: CONTENT ENTITIES AND …
Recipe list page Searchable list of recipes, with links to recipe detail pages
3. Decide which information is the most important on each page. Site visitors using mobile phones or other
small browsers will often only see the content that is presented first, and they may not scroll down to see
all of the information.
4. Decide which of these pages should appear in the main site navigation. For instance, the main navigation
might consist of the Home, About, Vendors, and Recipes pages.
5. Make a rough design sketch for each page, showing how it would look when viewed on a small screen such
as a phone, as well as on a larger screen such as a desktop browser. Considering that most site visitors
will be using smaller browsers, it is a good idea to start with the phone-size layout, to make sure that
these visitors will be able to find the information they need without too much scrolling.
In making these page layout plans, you might find that you need to revise your plan for which information
should be on which pages. For example, you might decide that the address, hours, and recently-added
recipes list would all fit well in the right sidebar area of all pages, when the site is viewed on desktop-sized
browsers. On the other hand, you might decide that for mobile browsers, you would instead put the
address and hours in a short format at the top of each page, but only display the recent recipe list at the
bottom of the home page.
9
CHAPTER 2. 规划您的站点 2.3. CONCEPT: CONTENT ENTITIES AND …
What is a field?
Within entity items, the data is stored in individual fields, each of which holds one type of data, such as
formatted or plain text, images or other files, or dates. Field types can be defined by the core software or by
modules.
Fields can be added by an administrator on entity sub-types, so that all entity items of a given entity sub-
type have the same collection of fields available. For example, the Vendor content type in the farmers market
example might have fields for the vendor name, a logo image, website URL, and description, whereas the Basic
page content type might only have fields for the title and page body. When you create or edit entity items, you
are specifying the values for the fields on the entity item.
Related topics
• Section 2.5, “Planning your Content Structure”
10
CHAPTER 2. 规划您的站点 2.4. CONCEPT: MODULAR CONTENT
Attributions
Written and edited by Jennifer Hodgdon and Grant Dunham.
Related topics
• Section 2.5, “Planning your Content Structure”
• Section 6.1, “Adding a Content Type”
• Section 6.3, “Adding Basic Fields to a Content Type”
• Section 6.4, “Concept: Reference Fields”
• Section 6.10, “Concept: View Modes and Formatters”
• Section 9.1, “Concept: Uses of Views”
Attributions
Written by Jennifer Hodgdon.
11
CHAPTER 2. 规划您的站点 2.5. PLANNING YOUR CONTENT STRUCTURE
Prerequisite knowledge
• Section 2.3, “Concept: Content Entities and Fields”
Steps
1. Brainstorm about what content your site needs to contain, which could include content that visitors would
be looking for, as well as content that you want to show to visitors. The result could be the description
in the section called “Guiding Scenario”.
2. For each identified piece of content, decide which content entity type would be the best fit. In doing this,
you’ll need to consider where and how the content will be used and edited on the site. For example, in
the farmers market site scenario, you might want to display the hours and location of the farmers market
on the sidebar of every page. For that content, a single custom block makes sense. As another example,
you might decide that pages displaying information about each vendor should be content items managed
by the core Node module, because you want vendors to be able to edit their own listings. The core Node
module permission system lets you do this easily.
These decisions do not necessarily always have only one right answer; for instance, you could decide that
vendor pages should be user profiles instead of content items, but if you did that the content would be
tied to a specific user account, and it would not be as easy to later change the ownership of a vendor page
to a different user account.
3. Within each content entity type you identified, decide what division into entity sub-types would make
sense. For example, in the farmers market site example, you would probably decide that under the Content
item entity type, there should be one content type for basic pages (Home and About), one for vendor
pages, and one for recipe pages.
4. For each entity sub-type you decided on, decide what fields are needed. For instance, the Vendor content
type might need fields for the vendor name, web page URL, image, and description.
5. Decide on what entity listings are needed, which could be entire pages or smaller areas on the page. For
each listing, you’ll need to determine what entity items should be listed. Then you’ll need to decide
in what order and with what filtering options they should be displayed; for example, you might want to
give the site visitor the option to search by keyword, to filter the list down to a subset, or to sort the list.
You’ll also need to decide what information from the entity items should be shown, which might result
in adding to the list of fields you determined in the previous step. The farmers market site, for example,
needs to have a Recipes listing page that lists content items of type Recipe, with the ability to filter by
ingredients, so that means that the Recipe content type needs an Ingredients field.
6. For each identified field on each entity subtype, identify what type of data it should contain (such as plain
text, formatted text, a date, an image file, etc.), and how many values should be allowed. Most fields are
single-valued, but for example, a Recipe should allow for multiple values in its Ingredients field.
7. Consider which fields would be best as references to taxonomy term entities: fields whose values should
be chosen from a list of allowed values. Allowed values that are expected to change and grow over time,
are good candidates. An example is the Ingredients field for the Recipe content type.
8. Consider which fields should reference other content entities. An example is that since vendors will be
submitting recipes, a field will be needed on the Recipe content type that references the Vendor content
item for the vendor who submitted the recipe.
Here’s an example of the resulting content structure for the farmers market scenario example site:
12
CHAPTER 2. 规划您的站点 2.6. CONCEPT: EDITORIAL WORKFLOW
Related concepts
Section 6.5, “Concept: Taxonomy”
Attributions
Written and edited by Jennifer Hodgdon and Grant Dunham.
13
CHAPTER 2. 规划您的站点 2.6. CONCEPT: EDITORIAL WORKFLOW
In your site, content types can have either a Published or an Unpublished flag to track their workflow states,
that you can set for each content item when saving:
Related topics
• Section 5.2, “Creating a Content Item”
Additional resources
Talking about online content, organizations would also want to consider post-publication phases of the editorial
workflow: content teams might need to update already published content. Some organizations might need a
more complex workflow with the options to configure which content type goes through the workflow process,
set up user roles and permissions, set different workflow states (for example draft, needs review, published).
For more complex workflows, you can add install or more modules from the contributed Workbench Suite
module to your site.
Attributions
Written and edited by Diána Lakatos at Pronovix, and Grant Dunham.
14
Chapter 3
安装
3.1 概念:服务器要求
运行核心软件的要求有哪些?
磁盘空间
最低安装需 15MB 磁盘空间。当网站安装大量的贡献模块和主题时需要 60MB 磁盘空间。谨记,你需要更多空
间用于数据库、用户上传的文件、媒体文件、备份文件及其他文件。
Web 服务器
数据库
可从下列数据库中任意选中一个:
PHP
PHP 5.5.9 或更高版本
15
CHAPTER 3. 安装 3.2. CONCEPT: ADDITIONAL TOOLS
相关资料
Drupal 官网文档:系统要求
贡献者
编写:Karl Kedrovsky 和 Brian Emery
翻译:周宇,冉强军 @ InterGreat Education Group
16
CHAPTER 3. 安装 3.3. PREPARING TO INSTALL
Some contributed modules also make use of externally-developed software libraries; for example, a Facebook
integration module might require Facebook’s integration library to be installed for the module to work, and a
geographical module might make use of a standard library of geographical functions. To install a module with
external dependencies, you will need to run Composer.
Coder Coder is a command-line tool that checks if your modules and themes comply with coding standards
and other best practices. It can also fix coding standard violations.
Firebug Firebug is a Firefox plugin that allows viewing, editing, debugging, and monitoring CSS, HTML,
and JavaScript in a separate browser window. The contributed Drupal for Firebug module displays Drupal
debugging and SQL query information in the Firebug window.
Related topics
Section 11.9, “Using Composer and Git to Download Files”
Additional resources
• Drupal.org community documentation page ”Development tools”
Attributions
Written and edited by Boris Doesborg and Jennifer Hodgdon.
Prerequisite knowledge
• Section 3.1, “概念:服务器要求”
Site prerequisites
If you want to use Drush to install the core software, Drush must be installed. See Section 3.2, “Concept:
Additional Tools”.
17
CHAPTER 3. 安装 3.3. PREPARING TO INSTALL
Steps
1. Choose a method for installing the core software.
Try a free online demo Use an online provider to get a demo installation of the core software in 20
minutes or less. See the Drupal.org page ”Try Drupal”.
Use a one-click installer from your hosting provider If you choose to install the core software at
your hosting provider, your hosting provider may have specific documentation and/or a one-click
install that you can use. See Drupal.org’s list of hosting providers that support Drupal.
Use Drush You will need to have Drush installed and command-line access to the site. See Section 3.2,
“Concept: Additional Tools”.
Use the web installer You will need space on a local or hosted web server to install the core software
manually.
Use a pre-configured environment Use a pre-configured environment or virtual machine that con-
tains Drupal and all the required supporting software to install Drupal locally. See the section for
your operating system under Drupal.org’s Local server setup guide for possible options.
2. If you are installing using Drush or the web installer, set up a URL and hosting for your site, either at
an external hosting provider or on your own computer. Verify that the hosting is working by putting a
simple HTML file in the web root directory of the hosting, and visiting the URL for your site.
3. If you are installing using Drush or the web installer, create a database, along with a database user account
with full access.
4. If you are installing using Drush, type the following at the Drush command line, where example is the
name of the directory that the core software will be downloaded to, and DB_NAME, DB_USER and
DB_PASS are your database’s credentials:
drush dl drupal --drupal -project - rename = example
cd example
drush site - install standard --db -url=' mysql :// DB_USER : DB_PASS@localhost /DB_NAME ' ←-
--site - name= example
5. If you are installing using the web installer, upload the core software files manually. To do this using
Git and/or Composer, see Section 11.9, “Using Composer and Git to Download Files”; to do this by
downloading a zipped archive:
b. Click the Download Drupal button (of the appropriate version) to be taken to the Downloads page.
18
CHAPTER 3. 安装 3.3. PREPARING TO INSTALL
g. Delete the compressed file from the server, unless your unpacking method already deleted it.
h. Rename the directory or reconfigure your web hosting, so that the directory name matches the
directory your web hosting is configured to use for your site.
19
CHAPTER 3. 安装 3.4. RUNNING THE INSTALLER
Additional resources
Drush
Attributions
Written and edited by Drew Gorton, Michael Lenahan at erdfisch, Jennifer Hodgdon, and Jojy Alphonso at
Red Crackle.
Prerequisite knowledge
Section 3.1, “概念:服务器要求”
Site prerequisites
Section 3.3, “Preparing to Install”
Steps
1. If you are using a 1-click install from a hosting provider or demo site, you will most likely see some or
all of the following screens as part of the installation process. If you uploaded the core files manually, to
start the installer, open a browser and visit the URL that you set up for your hosting.
2. Select a language on the first page of the installer; for example, English. You could optionally choose
from any of the other listed languages. The language files for the chosen language will be downloaded and
installed so that the rest of the installation process can be finished in the chosen language. After choosing
a language, click Save and continue.
3. Select an installation profile. Installation profiles provide site features and functions for a specific type
of site as a single download containing the core software, contributed modules, themes, and pre-defined
configuration. Core contains two installation profiles. Select the core Standard installation profile. Click
Save and continue.
20
CHAPTER 3. 安装 3.4. RUNNING THE INSTALLER
4. The next step in the installer will verify that your system meets the minimum requirements. If it does
not, you’ll be presented with an outline of what needs to be corrected in order to proceed. If it does, the
installer will automatically advance to the next step.
5. Provide details of the database you created in the Section 3.3,“Preparing to Install”chapter. Then click
Save and continue.
21
CHAPTER 3. 安装 3.4. RUNNING THE INSTALLER
6. The next step will display a progress bar under the heading Installing Drupal. After the installer has
completed, it will automatically advance to the next step.
22
CHAPTER 3. 安装 3.4. RUNNING THE INSTALLER
7. The final step is to configure some basic information about your new site. Note that the user account you
create in this step is the site’s admin account. See Section 7.2, “Concept: The User 1 Account”for
important information about this unique account. You can safely name this account ”admin”, and make
sure to choose a secure and unique password.
Fill in the form with the following information:
23
CHAPTER 3. 安装 3.4. RUNNING THE INSTALLER
24
CHAPTER 3. 安装 3.4. RUNNING THE INSTALLER
9. You will be redirected to the front page of your new site and you should see the message Congratulations,
you installed Drupal! displayed at the top of the page.
Related concepts
• Section 11.7, “Concept: Development Sites”
• Section 3.2, “Concept: Additional Tools”
Additional resources
Drupal.org community documentation page ”Create A Database”
Attributions
Written and edited by Joe Shindelar at Drupalize.Me, and Jojy Alphonso at Red Crackle.
25
Chapter 4
基本站点配置
Content Lists and manages existing content, and allows creation of new content.
Structure Contains a list of links for managing structural elements of the site, such as blocks, content types,
menus, and taxonomy.
Reports Contains links to logs, update information, search information, and other information about the
site’s status.
Help Lists help topics for installed modules that provide them.
The arrow button on the far right side of the second line of the toolbar (or far left side, if the site is
being viewed using a right-to-left-reading language like Arabic) can be used to switch the menu from appearing
horizontally at the top of the page, to a vertical format on the left side (or right side, in right-to-left languages).
When viewed vertically, the menu becomes an interactive tree.
27
CHAPTER 4. 基本站点配置 4.1. CONCEPT: ADMINISTRATIVE OVERVIEW
28
CHAPTER 4. 基本站点配置 4.1. CONCEPT: ADMINISTRATIVE OVERVIEW
This guide has a standard way to describe navigation to administrative pages using the administrative
toolbar. See the section called “Conventions of the Guide”for more information.
29
CHAPTER 4. 基本站点配置 4.2. EDITING BASIC SITE INFORMATION
Attributions
Written by Scott Wilkinson and Jennifer Hodgdon.
Prerequisite knowledge
Section 4.1, “Concept: Administrative Overview”
30
CHAPTER 4. 基本站点配置 4.2. EDITING BASIC SITE INFORMATION
Steps
Configuring the basic site information
1. In the Manage administrative menu, navigate to Configuration > System > Basic site settings (admin/config/system/site
information) to change the Site name, Slogan, administrative Email address, or the Default front page
path.
2. Fill in the available fields as appropriate for your site.
3. After editing the fields, click Save configuration to see the changes applied to the site.
31
CHAPTER 4. 基本站点配置 4.3. INSTALLING A MODULE
4. After editing the fields, click Save configuration to see the changes applied to the site.
Additional resources
Drupal.org community documentation page ”Getting started with Drupal 8 administration”
Attributions
Written and edited by Sree Veturi, Michael Lenahan at erdfisch, and Antje Lorch.
32
CHAPTER 4. 基本站点配置 4.3. INSTALLING A MODULE
Prerequisite knowledge
Section 1.2, “概念:模块”
Site prerequisites
If you want to use Drush to install modules, Drush must be installed. See Section 3.2, “Concept: Additional
Tools”.
Steps
You can use the administrative interface or Drush to install modules.
Using Drush
1. In the Manage administrative menu, navigate to Extend (admin/modules). The Extend page appears
showing all the available modules in your site.
2. Find the machine name of the module you want to install, by expanding the information area for the
module. For instance, the core Activity Tracker module’s machine name is tracker.
3. Run the following Drush command to install the module:
drush en tracker
Additional resources
Drush
Attributions
Written and edited by Boris Doesborg and Jennifer Hodgdon.
33
CHAPTER 4. 基本站点配置 4.4. UNINSTALLING UNUSED MODULES
Prerequisite knowledge
Section 1.2, “概念:模块”
Site prerequisites
• You must have at least one unused module on your site that you want to uninstall, such as the core Search
module.
• If you want to use Drush to uninstall modules, Drush must be installed. See Section 3.2, “Concept:
Additional Tools”.
Steps
You can use the administrative interface or Drush to uninstall modules.
Note
You cannot uninstall a module if it is required by some other module(s) and/or func-
tionality. For example, the core File module is required by the core Text Editor,
CKEditor, and Image modules. It can’t be uninstalled unless you uninstall its depen-
dent module(s) and functionality first. A module that cannot be uninstalled yet will
have a disabled checkbox, restricting you from uninstalling it.
3. Step 2 will prompt you to confirm the module uninstall request. Click Uninstall.
34
CHAPTER 4. 基本站点配置 4.4. UNINSTALLING UNUSED MODULES
35
CHAPTER 4. 基本站点配置 4.5. CONFIGURING USER ACCOUNT SETTINGS
Using Drush
1. In the Manage administrative menu, navigate to Extend (admin/modules). The Extend page appears
showing all the available modules in your site.
2. Find the machine name of the module you want to uninstall, by expanding the information area for the
module. For instance, the core Activity Tracker module’s machine name is tracker.
3. Run the following Drush command to uninstall the module:
drush pm - uninstall tracker
Attributions
Written and edited by Surendra Mohan, and Jojy Alphonso at Red Crackle.
Prerequisite knowledge
Section 4.1, “Concept: Administrative Overview”
Steps
1. In the Manage administrative menu, navigate to Configuration > People > Account settings (admin/con-
fig/people/accounts).
2. Under Registration and cancellation, select Administrators only as the people with permissions to register
user accounts. You can check Require email verification when a visitor creates an account in case you
want to change the settings for account registration later on.
36
CHAPTER 4. 基本站点配置 4.5. CONFIGURING USER ACCOUNT SETTINGS
3. Optionally, change the default email address from which user account notifications from the farmers
market website will be sent. This will help you maintain a separate email address from the one used for
the website in general. For example, this email address for user account notifications will be useful for a
staff member(s) communicating with vendors.
4. Optionally, edit the email templates in the Emails section to customize automated emails. There are seven
email templates available with the core. They are meant for different user-specific occasions. All of them
can be personalized and three can be disabled via checkboxes: activation, blocking, and cancellation.
You can send out your own text (for example, welcoming the new vendors for whom accounts were just
created) by editing the the Welcome (new user created by administrator) template.
37
CHAPTER 4. 基本站点配置 4.6. CONFIGURING THE THEME
Related concepts
See Chapter 7, 管理用户账号 for more information about user accounts and permissions.
Additional resources
Security Guide can help you with a more safety-focused approach to configuration.
Attributions
Written and edited by Laura Vass at Pronovix, and Jojy Alphonso at Red Crackle.
Prerequisite knowledge
Section 1.3, “概念:主题”
Steps
1. In the Manage administrative menu, navigate to Appearance (admin/appearance).
38
CHAPTER 4. 基本站点配置 4.6. CONFIGURING THE THEME
2. Under Installed themes, you will find Bartik listed as your default theme. Under Bartik (default theme),
click Settings.
3. Under Color scheme, click inside each color build box and type the proper color codes you would like to
add. For example, use the following colors:
Area Color
Header background top #7db84a (green)
Header background bottom #2a3524 (dark green)
Main background #ffffff (white)
Sidebar background #f8bc65 (light orange)
Sidebar borders #e96b3c (orange)
Footer background #2a3524 (dark green)
Title and slogan #ffffff (white)
Text color #000000 (black)
Link color #2a3524 (dark green)
Note: You can also use the color wheel on the right to select colors of your choice. The web color codes
will be added for you.
4. Under Logo image, uncheck Use the logo supplied by the theme.
39
CHAPTER 4. 基本站点配置 4.6. CONFIGURING THE THEME
5. Under Upload logo image, locate a logo file and upload it to your site. Note: You can also set a universal
logo for all themes under Appearance > Settings (admin/appearance/settings). A custom logo for your
theme will override the universal logo.
Once you have selected the file you would like to upload, you will see its filename next to the Choose File
or Browse button in your browser.
6. In order to save your changes and see the updated colors and logo on your site, click Save configuration
at the bottom of the page.
Note: Under Color scheme, there is a Preview section that displays a sample of how your website will
look with the new settings.
core Bartik theme settings preview
7. Click Return to site or Home in the toolbar to verify that you have updated the core Bartik theme settings
for your website.
40
CHAPTER 4. 基本站点配置 4.6. CONFIGURING THE THEME
Attributions
Written and edited by Ann Greazel, Amanda Luker at Advomatic, and Jack Haas.
41
Chapter 5
基本页面管理
What is a Path?
A path is the unique, last part of the URL for a specific function or piece of content. For example, for a page
whose full URL is http://example.com/node/7, the path is node/7.
Here are some examples of paths you might find in your site:
• node/7
• taxonomy/term/6
• admin/content/comment
• user/login
• user/3
What is an Alias?
The core software has a feature called ”URL Alias” that allows you to provide a more understandable name to
the content. So, if you have an ”About Us” page with the path node/7, you can set up an alias so that your
visitors will see it as http://www.example.com/AboutUs. The core Path module, which supports URL aliasing,
provides this functionality.
Related topics
• Section 5.2, “Creating a Content Item”
Attributions
Adapted by Diána Lakatos at Pronovix from ”URL aliases”, and ”Understanding Drupal paths” copyright
2000-2017 by the individual contributors to the Drupal Community Documentation
43
CHAPTER 5. 基本页面管理 5.2. CREATING A CONTENT ITEM
Prerequisite knowledge
Section 5.1, “Concept: Paths, Aliases, and URLs”
Site prerequisites
The Basic page content type must exist. This is created on your site when you install with the core Standard
installation profile.
Steps
1. In the Manage administrative menu, navigate to Content > Add content > Basic page (node/add/page).
The Create Basic page form appears.
2. Click Edit summary.
3. Fill in the fields as shown below.
By clicking the Source button in the rich text editor toolbar, you can see the HTML source code of the
text that you are editing.
44
CHAPTER 5. 基本页面管理 5.2. CREATING A CONTENT ITEM
6. Click Save and publish. The content is saved and can be found on the Content page.
7. Follow the same steps to create an About page, with title ”About”, and a body telling about the history
of the farmer’s market.
Related concepts
• Section 10.1, “Concept: User Interface, Configuration, and Content translation”
45
CHAPTER 5. 基本页面管理 5.3. EDITING A CONTENT ITEM
Additional resources
Drupal.org community documentation page ”About nodes”
Attributions
Written by Agnes Kiss and Boris Doesborg.
Prerequisite knowledge
Section 5.2, “Creating a Content Item”
Site prerequisites
A content item for the Home page must exist. See Section 5.2, “Creating a Content Item”.
Steps
1. In the Manage administrative menu, navigate to Content (admin/content).
2. If the content item you want to edit was updated or created recently, it should appear near the top of the
content list on that page. If not, you can use the Content type, Title, or other filters to locate the content
item.
3. Click Edit in the row of the content item you want to edit (Home), to open the content editing form.
Update the opening hours in the Body field. See Section 5.2,“Creating a Content Item”for an explanation
of the fields and a screenshot.
4. Check Create new revision in the box on the right, if it is not already checked, and enter a Revision
log message explaining what changes you are making (for example, you might enter ”Updated opening
hours”). This text will appear in the revision log for the page.
46
CHAPTER 5. 基本页面管理 5.4. EDITING WITH THE IN-PLACE EDITOR
Prerequisite knowledge
• Section 2.3, “Concept: Content Entities and Fields”
• Section 5.2, “Creating a Content Item”
• Section 5.3, “Editing a Content Item”
• Section 4.1, “Concept: Administrative Overview”
47
CHAPTER 5. 基本页面管理 5.4. EDITING WITH THE IN-PLACE EDITOR
Site prerequisites
The About page you want to edit must exist. See Section 5.2, “Creating a Content Item”.
Steps
Navigate to the About page to edit content with the in-place editor. If the page has not yet been added to a
navigation menu, you can find and open it by following these steps:
Once the content you want to edit is being viewed in your browser, follow these steps to use the quick editor:
1. Find the section of the page that displays the content you want to edit, and turn on quick editing mode
using the Quick edit contextual link (see Section 4.1,“Concept: Administrative Overview”for instructions
on how to access contextual links). You will see each editable field on this content item outlined in blue;
also, a hovering dialog box will appear.
2. Click the Body text area to begin editing. The Body field supports a rich text editor. The editing toolbar
will be displayed in a hovering dialog box.
3. Add some information about City Market. A Save button will appear in the hovering dialog box, and the
field outline will change color.
4. If you are satisfied with your edits, click Save in the hovering dialog box. If not, click ”x” to discard your
edits, and confirm. Either way, quick editing mode will be turned off.
48
CHAPTER 5. 基本页面管理 5.5. DESIGNATING A FRONT PAGE FOR …
Site prerequisites
The content item that you want to designate as the front page of your site must exist. See Section 5.2,“Creating
a Content Item”.
Steps
1. In the Manage administrative menu, navigate to Configuration > System > Basic site settings (admin/config/system/site
information).
2. Under Front page, replace /node with the name of the page you would like to make the home page. To
use the home page that was previously created, provide its path /home. Click Save configuration.
3. Navigate to the home page to verify that it displays content as configured by you.
49
CHAPTER 5. 基本页面管理 5.6. CONCEPT: MENU
• Follow Section 5.2, “Creating a Content Item”to create an error page to be used as a 404 (page not
found) or 403 (not authorized) response on your site. Then following the steps here, you can designate it
as the error response, in the Error pages section of the configuration.
Related concepts
Section 5.6, “Concept: Menu”
Attributions
Written and edited by Ann Greazel, Jack Haas, and Jojy Alphonso at Red Crackle.
Tools Links to tasks necessary for site visitors. Some modules feature their links here.
You can customize menus in the following ways, using the menu administration functionality:
• Creating new custom menus.
• Adding new menu items.
• Reordering menu items by setting their ”weight” or by dragging them into place.
• Renaming menu items.
• Changing the link title (the tooltip that appears when you mouse over a menu item).
• Moving a menu item into a different menu by editing its Parent property.
A menu item will only be shown to a visitor if they have the rights to view the page it links to. For example,
the admin menu item is not shown to visitors who are not logged in.
Related topics
• Section 5.7, “Adding a Page to the Navigation”
• Section 5.8, “Changing the Order of Navigation”
50
CHAPTER 5. 基本页面管理 5.7. ADDING A PAGE TO THE NAVIGATION
• To display a menu, you will need to place the block that corresponds to the menu in a region of your theme;
see Section 8.1, “Concept: Blocks”, Section 2.1, “Concept: Regions in a Theme”, and Section 8.3,
“Placing a Block in a Region”. The core Standard installation profile places all of the menus it defines
except Administration in regions of the core Bartik theme. The core Toolbar module, which is installed
by the core Standard installation profile, displays the Administration menu; it is also displayed by the
contributed Admin Toolbar module.
Attributions
Written and edited by Ajay Viswambharan, Jojy Alphonso at Red Crackle, and Jennifer Hodgdon.
Prerequisite knowledge
• Section 5.6, “Concept: Menu”
• Section 5.3, “Editing a Content Item”
Site prerequisites
The About page content item must exist. See Section 5.2, “Creating a Content Item”.
Steps
1. In the Manage administrative menu, navigate to Content (admin/content).
2. Find the About page, and click Edit in that row. The content editing form appears.
6. Click Save and keep published to save the changes. Click Home or Return to site in the navigation bar to
see the result, which could look like the picture below.
52
CHAPTER 5. 基本页面管理 5.8. CHANGING THE ORDER OF NAVIGATION
Additional resources
Drupal.org community documentation page ”Working with menus”
Attributions
Adapted by Boris Doesborg from ”Working with Menus”, copyright 2000-2017 by the individual contributors
to the Drupal Community Documentation; edited by Jack Haas.
Prerequisite knowledge
• Section 5.6, “Concept: Menu”
• Section 5.7, “Adding a Page to the Navigation”
Site prerequisites
Home and About pages must exist in the main navigation menu. See Section 5.7, “Adding a Page to the
Navigation”.
53
CHAPTER 5. 基本页面管理 5.8. CHANGING THE ORDER OF NAVIGATION
Steps
1. In the Manage administrative menu, navigate to Structure > Menus (admin/structure/menu) where all
menus on your site are listed. Click Edit Menu from the Operations dropdown for Main navigation. You
can also reach this page using contextual links (refer to Section 4.1,“Concept: Administrative Overview”
) for the menu.
2. The Edit menu page will display a list of each item in the menu you chose (Main navigation).
3. Use the cross bar handles to reorder the menu items. Drag the Home menu item above the About menu
item so that it appears first.
54
CHAPTER 5. 基本页面管理 5.8. CHANGING THE ORDER OF NAVIGATION
4. Click Save.
5. The home page now displays the main navigation with the Home menu item displayed first.
Related concepts
Section 5.6, “Concept: Menu”
55
CHAPTER 5. 基本页面管理 5.8. CHANGING THE ORDER OF NAVIGATION
Attributions
Written by Ann Greazel.
56
Chapter 6
内容结构
Prerequisite knowledge
Section 2.3, “Concept: Content Entities and Fields”
Site prerequisites
You need to have a plan in place for your content structure. See Section 2.5,“Planning your Content Structure”
.
Steps
1. In the Manage administrative menu, navigate to Structure > Content types (admin/structure/types). The
Content types page appears showing all the available types of content.
2. Click Add content type. The Add content type page appears. Fill in the fields as shown below.
57
CHAPTER 6. 内容结构 6.1. ADDING A CONTENT TYPE
3. In the vertical tab Submission form settings, configure the form that is used for creating and editing
content of this type. Fill in the fields as shown below.
58
CHAPTER 6. 内容结构 6.1. ADDING A CONTENT TYPE
4. In the vertical tab Publishing options, decide on default options for new content of this type. Fill in the
fields as shown below.
Changing these settings does not affect the content items that have already been created.
59
CHAPTER 6. 内容结构 6.1. ADDING A CONTENT TYPE
5. In the vertical tab Display settings, decide if the author and publication date will be visible in the content
item. Fill in the fields as shown below.
6. In the vertical tab Menu settings, fill in the fields as shown below.
60
CHAPTER 6. 内容结构 6.1. ADDING A CONTENT TYPE
7. Click Save and manage fields to save the content type. The Manage fields page appears that allows you
to add fields to the content type. See Section 6.3, “Adding Basic Fields to a Content Type”
8. Follow the same steps to create a content type for recipes. Example values for the fields in the forms,
where they are different from the steps above:
61
CHAPTER 6. 内容结构 6.2. DELETING A CONTENT TYPE
Prerequisite knowledge
Section 4.1, “Concept: Administrative Overview”
Site prerequisites
The Article content type must exist. It is created on your site when you install with the core Standard installation
profile.
Steps
1. In the Manage administrative menu, navigate to Structure > Content types (admin/structure/types). The
Content types page appears.
2. Click Delete in the Operations dropdown button for the Article content type.
62
CHAPTER 6. 内容结构 6.2. DELETING A CONTENT TYPE
63
CHAPTER 6. 内容结构 6.3. ADDING BASIC FIELDS TO A CONTENT …
4. The Content types page appears with a confirmation message saying that the content type has been
deleted:
Attributions
Written and edited by Sree Veturi and Boris Doesborg.
Prerequisite knowledge
Section 2.3, “Concept: Content Entities and Fields”
Site prerequisites
The Vendor content type must exist. See Section 6.1, “Adding a Content Type”.
Steps
Add the fields Vendor URL and Main image to the Vendor content type.
1. In the Manage administrative menu, navigate to Structure > Content types (admin/structure/types). Then
click Manage fields in the dropdown button for the Vendor content type. The Manage fields page appears.
2. Click Add field. The Add field page appears. You can either create a new field for the content type or
re-use an existing field.
3. Fill in the fields as shown below.
A machine name is automatically generated, based on the Label value. Click Edit if you want to override
the default name.
64
CHAPTER 6. 内容结构 6.3. ADDING BASIC FIELDS TO A CONTENT …
4. Click Save and continue. The page Vendor URL appears which lets you set the allowed number of values.
Fill in the fields as shown below.
5. Click Save field settings. The page Vendor URL settings for Basic page appears which allows you to
configure the field. Fill in the fields as shown below.
65
CHAPTER 6. 内容结构 6.3. ADDING BASIC FIELDS TO A CONTENT …
66
CHAPTER 6. 内容结构 6.3. ADDING BASIC FIELDS TO A CONTENT …
67
CHAPTER 6. 内容结构 6.3. ADDING BASIC FIELDS TO A CONTENT …
6. Click Save settings. The Vendor URL has been added to the content type. Continue creating the Main
image field.
7. Click Add field. The Add field page appears. Fill in the fields as shown below.
8. Click Save and continue. The page Main image appears. Fill in the fields as shown below.
You can set a default image here. This will be used when you do not provide an image when creating a
Vendor content item.
9. Click Save field settings. The page Main image settings for Basic page appears. Fill in the fields as shown
below.
68
CHAPTER 6. 内容结构 6.3. ADDING BASIC FIELDS TO A CONTENT …
69
CHAPTER 6. 内容结构 6.4. CONCEPT: REFERENCE FIELDS
10. Click Save settings. Main image has been added to the content type.
11. Add a Main image field to the Recipe content type, using similar steps. Start by navigating to the Recipe
content type’s Manage Fields page in step 1. Then skip to step 7 and follow the remaining steps, but
reuse the existing Main image field you created for the Vendor content type rather than creating a new
field. In subsequent steps, some of the configuration screens will not be available, because of the field
reuse.
12. Create two Vendor content items (see Section 5.2, “Creating a Content Item”) called ”Happy Farm”
and ”Sweet Honey”. Make sure that they include images and URLs.
Additional resources
Drupal.org community documentation page ”Add a field to a content type”
Attributions
Written by Sree Veturi and Boris Doesborg.
70
CHAPTER 6. 内容结构 6.5. CONCEPT: TAXONOMY
Content reference A reference to a content item. For example, you might want to connect recipes to the
vendors who submitted them. You would set up a content reference field called Submitted by referencing
Vendor content items on the Recipe content type.
Taxonomy term reference A reference to a taxonomy term. For example, you might want to connect
recipes to their ingredients. You would set up a taxonomy term reference field called Ingredients on the
Recipe content type. This reference field will point to the vocabulary Ingredients.
User reference A reference to a user account. For example, you might want to connect recipes with their
chefs. You would set up a user reference field called Chefs on the Recipe content type.
Related topics
Section 6.5, “Concept: Taxonomy”
Attributions
Written and edited by Surendra Mohan, and Jojy Alphonso at Red Crackle.
What is Taxonomy?
Taxonomy is used to classify website content. One common example of taxonomy is the tags used to classify
or categorize posts in a blog website; the farmers market website could use an ingredients taxonomy to classify
recipes. Individual taxonomy items are known as terms (the blog tags or recipe ingredients in these examples);
and a set of terms is known as a vocabulary (the set of all blog post tags, or the set of all recipe ingredients in
these examples). Technically, taxonomy terms are an entity type and the entity subtypes are the vocabularies.
Like other entities, taxonomy terms can have fields attached; for instance, you could set up an image field to
contain an icon for each term.
An individual vocabulary can organize its terms in a hierarchy, or it could be flat. For example, blog
tags normally have a flat structure, while a recipe ingredients vocabulary could be hierarchical (for example,
tomatoes could be a sub-term of vegetables, and under tomatoes, you could have green and red tomatoes).
Taxonomy terms are normally attached as reference fields to other content entities, which is how you can
use them to classify content. When you set up a taxonomy reference field, you can let users enter terms in two
ways:
Free tagging New terms can be created right on the content editing form.
Fixed list of terms The list of terms is curated and managed outside the content editing form, and users
can only choose from the existing list when editing content.
Taxonomy reference fields can be added to any entity, such as user accounts, custom blocks, or regular
content items. If you use them to classify regular content items, your site will automatically be set up with
taxonomy listing pages for each term; each of these pages lists all of the content items that are classified with
that term. For example, if you created several recipes that all had carrots as an ingredient, you might see
something like this on the Carrots taxonomy listing page:
71
CHAPTER 6. 内容结构 6.5. CONCEPT: TAXONOMY
72
CHAPTER 6. 内容结构 6.6. SETTING UP A TAXONOMY
Related topics
• Section 6.6, “Setting Up a Taxonomy”.
• The listing pages are views, which are covered in Chapter 9, 用视图创建列表.
Attributions
Adapted and edited by Surendra Mohan, Jennifer Hodgdon, and Jojy Alphonso at Red Crackle from ”Orga-
nizing content with taxonomies” and ”About taxonomies”, copyright 2000-2017 by the individual contributors
to the Drupal Community Documentation.
Prerequisite knowledge
• Section 2.3, “Concept: Content Entities and Fields”
• Section 6.5, “Concept: Taxonomy”
• Section 6.3, “Adding Basic Fields to a Content Type”
Site prerequisites
The Recipe content type must exist. See Section 6.1, “Adding a Content Type”.
Steps
1. In the Manage administrative menu, navigate to Structure > Taxonomy (admin/structure/taxonomy).
You will see the Tags vocabulary that was created with the core Standard installation profile.
73
CHAPTER 6. 内容结构 6.6. SETTING UP A TAXONOMY
3. Click Save. You will be taken to the Ingredients page, which shows a list of all the terms in this vocabulary.
74
CHAPTER 6. 内容结构 6.6. SETTING UP A TAXONOMY
4. Click Add term. Enter ”Butter” in the Name field. Click Save.
75
CHAPTER 6. 内容结构 6.6. SETTING UP A TAXONOMY
5. You will receive a confirmation about the term you created. Add more terms. For example, ”Eggs” and
”Milk”.
76
CHAPTER 6. 内容结构 6.6. SETTING UP A TAXONOMY
6. In the Manage administrative menu, navigate to Structure > Content Types (admin/structure/types).
Click Manage fields for your Recipe content type.
7. Click Add field, and enter values from the table below. Click Save and continue.
8. On the following configuration screen, enter the values from the table below. Click Save field settings.
77
CHAPTER 6. 内容结构 6.6. SETTING UP A TAXONOMY
9. On the following configuration screen, enter the values from the table below. Click Save settings.
78
CHAPTER 6. 内容结构 6.6. SETTING UP A TAXONOMY
10. Click Save settings. You will be taken back to the Manage Fields page. A message will be displayed saying
that the configuration for Ingredients is complete.
79
CHAPTER 6. 内容结构 6.7. ADDING A REFERENCE FIELD
Attributions
Written and edited by Bob Snodgrass, and Jojy Alphonso at Red Crackle.
Prerequisite knowledge
• Section 6.3, “Adding Basic Fields to a Content Type”
Site prerequisites
The Recipe and Vendor content types must exist. See Section 6.1, “Adding a Content Type”.
Steps
1. In the Manage administrative menu, navigate to Structure > Content types (admin/structure/types). Then
click Manage fields in the dropdown button for the Recipe content type. The Manage fields page appears.
2. Click Add field. The Add field page appears. Fill in the fields as shown below. Click Save and continue.
80
CHAPTER 6. 内容结构 6.7. ADDING A REFERENCE FIELD
3. The page Submitted by appears which lets you set the allowed number of values. Fill in the fields as
shown below. Click Save field settings.
4. The page Submitted by settings for Recipe appears which allows you to configure the field. Fill in the fields
as shown below. Click Save settings.
81
CHAPTER 6. 内容结构 6.7. ADDING A REFERENCE FIELD
82
CHAPTER 6. 内容结构 6.8. CONCEPT: FORMS AND WIDGETS
Attributions
Written and edited by Boris Doesborg, and Jojy Alphonso at Red Crackle.
• Select a widget for each field. A widget defines the method used to enter the data for the field. For
example, a taxonomy term can be chosen using an autocomplete field, a select list, or a tags-style field
that lets editors add new tags automatically.
• Configure widget settings. For example, you can choose the size of a plain-text entry field.
• Hide one or more fields from the editing form.
83
CHAPTER 6. 内容结构 6.9. CHANGING CONTENT ENTRY FORMS
Related topics
• Section 6.9, “Changing Content Entry Forms”
Attributions
Written by Jennifer Hodgdon.
Prerequisite knowledge
• Section 6.1, “Adding a Content Type”
• Section 6.3, “Adding Basic Fields to a Content Type”
• Section 6.5, “Concept: Taxonomy”
• Section 6.8, “Concept: Forms and Widgets”
Site prerequisites
The Recipe content type must exist, and it must have an Ingredients taxonomy term reference field. See
Section 6.1, “Adding a Content Type”and Section 6.6, “Setting Up a Taxonomy”.
Steps
1. In the Manage administrative menu, navigate to Content > Add content > Recipe (node/add/recipe) to
look at the content entry form that is set up by default. Notice how you have to enter ingredients one by
one, instead of having a more compact format.
2. In the Manage administrative menu, navigate to Structure > Content types (admin/structure/types). Then
click Manage form display on the dropdown button for the Recipe content type. The Manage form display
page appears.
3. For the Ingredients field, select Autocomplete (Tags style) in the Widget column.
84
CHAPTER 6. 内容结构 6.9. CHANGING CONTENT ENTRY FORMS
85
CHAPTER 6. 内容结构 6.9. CHANGING CONTENT ENTRY FORMS
4. Click Save.
5. In the Manage administrative menu, navigate to Content > Add content > Recipe (node/add/recipe) to
verify the changed behavior of the content form. The Ingredients field is now a single text field that
accepts multiple values.
6. Create two Recipe content items (see Section 5.2, “Creating a Content Item”), such as recipes for
”Green Salad” and ”Fresh Carrots”. Make sure all the fields have values, including images, ingredients,
and submitted by (set this to one of the Vendor content items you created in Section 6.3, “Adding Basic
Fields to a Content Type”).
86
CHAPTER 6. 内容结构 6.10. CONCEPT: VIEW MODES AND …
• a teaser of the content with a thumbnail image and a Read more link
• a full user profile with a zoomable portrait photo
• a user avatar with username and a link to the profile
Every view mode can be configured through the administration pages. To see the configuration options
for the view modes of the Recipe content type, navigate in the Manage administrative menu to Structure >
Content types (admin/structure/types) and click Manage display from the dropdown button. In each view mode,
all fields can be hidden or displayed, and if they are displayed, you can choose and configure the field formatter.
Related topics
• Section 6.1, “Adding a Content Type”
• Section 6.11, “Changing Content Display”
Additional resources
Drupal.org community documentation page ”View modes”
Attributions
Adapted by Boris Doesborg from ”View modes”, copyright 2000-2017 by the individual contributors to the
Drupal Community Documentation.
Prerequisite knowledge
• Section 2.3, “Concept: Content Entities and Fields”
• Section 6.10, “Concept: View Modes and Formatters”
87
CHAPTER 6. 内容结构 6.11. CHANGING CONTENT DISPLAY
Site prerequisites
The Vendor content type must exist, it must have Main Image and Vendor URL fields, and your site must have
at least one Vendor content item. See Section 6.1, “Adding a Content Type”, Section 6.3, “Adding Basic
Fields to a Content Type”, and Section 5.2, “Creating a Content Item”.
Steps
1. Find and view a Vendor content item you created in Section 6.3, “Adding Basic Fields to a Content
Type”. Notice that there are several things that could be done to improve how the page looks:
• The Main Image and Vendor URL fields should not have labels.
• The order of the fields should be changed so that the image comes first.
• The image should be smaller.
2. To fix the first two problems, and update some additional settings, in the Manage administrative menu,
navigate to Structure > Content types (admin/structure/types). Then click Manage display in the drop-
down button for the Vendor content type.
3. Under the Label column, select Hidden for Main image. Do the same for Vendor URL.
88
CHAPTER 6. 内容结构 6.11. CHANGING CONTENT DISPLAY
4. Click the gear for the Vendor URL field. Clear the Trim link text length setting. Links will no longer have
a trim length. Check the Open link in new window checkbox. Now, when the link is clicked, it will open
in a new browser window. Click Update.
89
CHAPTER 6. 内容结构 6.11. CHANGING CONTENT DISPLAY
5. Drag the cross arrows next to the field items to reorder as Main image, Body, Vendor URL, and Links.
90
CHAPTER 6. 内容结构 6.12. CONCEPT: IMAGE STYLES
6. Click Save.
7. Find the Vendor content item from step 1 again, and verify that the updates have been made.
8. Repeat similar steps to manage the display of the Recipe content type fields.
Related concepts
Section 6.12, “Concept: Image Styles”
Additional resources
• Drupal.org community documentation page ”Specify how fields are displayed”
• Drupal.org community documentation page ”Rearrange the order of fields”
Attributions
Written by Ann Greazel and Boris Doesborg.
91
CHAPTER 6. 内容结构 6.13. SETTING UP AN IMAGE STYLE
Related topics
• Section 6.13, “Setting Up an Image Style”
• Section 6.14, “Concept: Responsive Image Styles”
• Section 6.3, “Adding Basic Fields to a Content Type”
Additional resources
Drupal.org community documentation page ”Working with images in Drupal 7 and 8”
Attributions
Adapted and edited by Boris Doesborg, and Jojy Alphonso at Red Crackle, from ”Working with images in
Drupal 7 and 8”, copyright 2000-2017 by the individual contributors to the Drupal Community Documentation
Prerequisite knowledge
• Section 6.3, “Adding Basic Fields to a Content Type”
• Section 6.11, “Changing Content Display”
• Section 6.12, “Concept: Image Styles”
Site prerequisites
• Vendor and Recipe content types must exist. See Section 6.1, “Adding a Content Type”.
• Main image fields must exist for both content types. See Section 6.3, “Adding Basic Fields to a Content
Type”.
• Content items must exist for both content types. See Section 6.1,“Adding a Content Type”, Section 6.3,
“Adding Basic Fields to a Content Type”, and Section 5.2, “Creating a Content Item”.
92
CHAPTER 6. 内容结构 6.13. SETTING UP AN IMAGE STYLE
Steps
1. In the Manage administrative menu, navigate to Configuration > Media > Image styles (admin/config/media/image-
styles).
2. Click Add image style.
3. Enter the name Extra medium (300x200)
4. Click Create new style. The page Edit style Extra medium (300x200) appears.
7. Click Add effect. The image style is saved with the chosen effects.
93
CHAPTER 6. 内容结构 6.13. SETTING UP AN IMAGE STYLE
94
CHAPTER 6. 内容结构 6.13. SETTING UP AN IMAGE STYLE
8. In the Manage administrative menu, navigate to Structure > Content types (admin/structure/types).
9. Click Manage display in the Operations dropdown for the Vendor content type. The Manage display page
(admin/structure/types/manage/vendor/display) appears.
10. Ensure that the secondary tab Default is selected.
11. Click the cogwheel next to Main image for the configuration options.
15. Open a Vendor content item and verify that it now shows up with the scaled-down image. See Section 5.3,
“Editing a Content Item”for information on how to locate an existing content item.
16. Repeat steps 8-15 for the Recipe content type.
Related concepts
• Section 6.3, “Adding Basic Fields to a Content Type”
• Section 6.12, “Concept: Image Styles”
95
CHAPTER 6. 内容结构 6.14. CONCEPT: RESPONSIVE IMAGE STYLES
Additional resources
Drupal.org community documentation page ”Working with images in Drupal 7 and 8”
Attributions
Adapted and edited by Boris Doesborg, and Jojy Alphonso at Red Crackle from ”Working with images in
Drupal 7 and 8”, copyright 2000-2017 by the individual contributors to the Drupal Community Documentation.
Related topics
Section 6.3, “Adding Basic Fields to a Content Type”
Additional resources
• Drupal.org community documentation page ”Responsive web design”
Attributions
Adapted by Boris Doesborg from Responsive images in Drupal 8, copyright 2000-2017 by the individual
contributors to the Drupal Community Documentation.
96
CHAPTER 6. 内容结构 6.16. CONFIGURING TEXT FORMATS AND …
Related topics
Section 13.3, “Concept: Security and Regular Updates”
Additional resources
• Drupal.org community documentation page ”Filter module: text formats that filter user input”
• Wikipedia page ”Cross-site scripting”
Attributions
Written and edited by Boris Doesborg and Jennifer Hodgdon.
Prerequisite knowledge
Section 6.15, “Concept: Text Formats and Editors”
Site prerequisites
• The core Filter, Editor, and CKEditor modules must be installed. They are installed on your site when
you install with the core Standard installation profile.
• The Basic HTML text format must exist. This is created on your site when you install with the core
Standard installation profile.
Steps
1. In the Manage administrative menu, navigate to Configuration > Content authoring > Text formats and
editors (admin/config/content/formats). The Text formats and editors page appears.
2. Click Configure for the Basic HTML text format. The Basic HTML page appears.
3. Note that CKEditor is selected in the Text editor field. This allows you to configure the editor’s toolbar.
97
CHAPTER 6. 内容结构 6.16. CONFIGURING TEXT FORMATS AND …
4. Drag the horizontal rule button from Available buttons to Tools in Active toolbar. You may need to click
the Show group names link to see the Tools group name.
7. Click Save configuration. You will be taken back to the Text formats and editors page. A message will be
displayed saying that the text format has been updated.
98
Chapter 7
管理用户账号
7.1 概念:用户,角色和权限
什么是用户?
访问网站的任何人都是用户,包括您自己。有三类用户:
• 未登录用户,或匿名用户
• 已登录用户
• 安装网站时自动创建的管理员账号,或用户 1。请查看 Section 7.2, “Concept: The User 1 Account”。
什么是权限?
权限决定用户是否能够在网站上执行操作(包括浏览内容,编辑内容,以及改变配置)。每个权限都有一个名
字 (比如:查看已发布内容) ,它控制一个操作或者多个操作。用户必须被授予权限才能在站点上执行相应的操
作。权限由提供操作的模块定义。
什么是角色?
不同于直接为每个用户单独分配权限,角色包含一组权限. 您可以在网站上定义一个或更多角色, 然后分配不同
的权限给不同的角色。授予给已登录用户和匿名用户的权限分别包含在已登录用户角色和匿名用户角色中。取
决于您在安装站点时选择的安装类型,可能会创建有一个叫管理员的角色。这个角色拥有所有的权限。
每个账号会自动获得已登录用户角色,同时,每个账号可以拥有一个或多个其他角色。当将角色分配给账
号后,该账号对应的用户在登录时将拥有该角色拥有的所有权限。
创建多个角色是一种好的实践。以农贸市场站点为例,可能需要以下角色:
• 供应商角色,允许供应商编辑自己的供应商列表页面
• 内容编辑角色,用于编辑一般农贸市场页面
• 用户管理员角色,用于管理供应商帐户
• 管理员角色,安装网站时自动创建,供高级用户管理站点配置
相关话题
• Section 7.3, “Creating a Role”
• Section 7.5, “Assigning Permissions to a Role”
99
CHAPTER 7. 管理用户账号 7.2. CONCEPT: THE USER 1 ACCOUNT
相关资料
• Drupal 官网文档:用户,角色和权限
• Drupal 官网文档:管理用户
• Drupal 官网文档:用户角色
贡献者
编写:Mark LaCroix,Boris Doesborg,和 Jennifer Hodgdon 改编自 用户角色,© 2000-2017 Drupal 社区
文档贡献者
翻译:冉强军 @ InterGreat Education Group,qingguo
• The Administrator role permissions can be modified to be safer than the full permissions of the user 1
account, so that people do not inadvertently change site features that shouldn’t be changed.
• People’s responsibilities on a site may change over time. With ordinary user accounts, this can be
mirrored in permissions by assigning or unassigning roles to their user accounts. If they are all using the
user 1 account, this is more difficult.
• On some sites, the author of content or comments is displayed or tracked, and if everyone uses the same
account to create content, it is difficult to know who created the content.
It is not possible to delete the user 1 account from the administrative user interface. It would be possible
to do with a database query, but it could cause problems in your site and is not advisable.
Additional resources
Drupal.org community documentation page ”Accounts and roles”
Attributions
Written and edited by Mark LaCroix and Jennifer Hodgdon.
100
CHAPTER 7. 管理用户账号 7.3. CREATING A ROLE
Prerequisite knowledge
Section 7.1, “概念:用户,角色和权限”
Steps
1. In the Manage administrative menu, navigate to People > Roles (admin/people/roles).
2. You will find default roles Anonymous user, Authenticated user, and Administrator already present.
101
CHAPTER 7. 管理用户账号 7.3. CREATING A ROLE
102
CHAPTER 7. 管理用户账号 7.4. CREATING A USER ACCOUNT
5. You will see the message ”Role Vendor has been added.” displayed at the top of the page.
Additional resources
Drupal.org community documentation page ”User Roles”
Attributions
Adapted and edited by Jack Probst, Boris Doesborg, and Joe Shindelar from ”User Roles”, copyright 2000-
2017 by the individual contributors to the Drupal Community Documentation
Prerequisite knowledge
• Section 7.1, “概念:用户,角色和权限”
• Section 7.2, “Concept: The User 1 Account”
• Section 7.3, “Creating a Role”
103
CHAPTER 7. 管理用户账号 7.4. CREATING A USER ACCOUNT
Site prerequisites
The Vendor role must exist on your site. See Section 7.3, “Creating a Role”.
Steps
1. In the Manage administrative menu, navigate to People (admin/people).
2. Click Add user.
104
CHAPTER 7. 管理用户账号 7.4. CREATING A USER ACCOUNT
4. Click Create new account. You will get a notification about the user account creation.
5. Create a second Vendor account for Happy Farm by following the steps above.
105
CHAPTER 7. 管理用户账号 7.5. ASSIGNING PERMISSIONS TO A ROLE
Prerequisite knowledge
• Section 7.1, “概念:用户,角色和权限”
Site prerequisites
The Vendor role must exist on your site. See Section 7.3, “Creating a Role”.
Steps
1. In the Manage administrative menu, navigate to People > Roles (admin/people/roles). The Roles page
appears.
2. Click Edit permissions in the dropdown for the Vendor role. The Edit role page appears where you can
see all the available actions for the website such as, for example, Post comments or Administer blocks.
The available permissions depend on the modules that are installed in the site. Note: Some permissions
may have security implications. Be cautious while assigning permissions to roles.
Module Permission
Contact Use users’ personal contact forms
Filter Use the Restricted HTML text format
Node Recipe: Create new content
Node Recipe: Edit own content
Node Recipe: Delete own content
Node Vendor: Edit own content
Quick Edit Access in-place editing
106
CHAPTER 7. 管理用户账号 7.5. ASSIGNING PERMISSIONS TO A ROLE
4. Click Save permissions. You will get a message saying your changes have been saved.
107
CHAPTER 7. 管理用户账号 7.6. CHANGING A USER’S ROLES
Related concepts
Section 7.2, “Concept: The User 1 Account”
Additional resources
Drupal.org community documentation page ”Managing Users”
Attributions
Adapted and edited by Boris Doesborg, Brian Emery, and Jojy Alphonso at Red Crackle, from ”User Roles”,
copyright 2000-2017 by the individual contributors to the Drupal Community Documentation.
Prerequisite knowledge
Section 7.1, “概念:用户,角色和权限”
Site prerequisites
The user account that you want to update, and the role you want it to have, must already exist. See Section 7.4,
“Creating a User Account”, Section 7.3, “Creating a Role”, and Section 7.5, “Assigning Permissions to a
Role”.
Steps
Updating the roles using single-user editing method
1. In the Manage administrative menu, navigate to People (admin/people).
2. Locate the user 1 account (named ”admin”) to assign it the Administrator role. If it is not immediately
visible, use the Name or email contains filter, or other filters, to narrow down the list.
3. Click Edit to update the user account.
108
CHAPTER 7. 管理用户账号 7.6. CHANGING A USER’S ROLES
4. On the Edit page, scroll down to Roles section. Check the Administrator role for the user account.
5. Click Save to update the user account. You should be returned to the People page and see a message
saying that the changes have been saved.
109
CHAPTER 7. 管理用户账号 7.7. ASSIGNING AUTHORS TO CONTENT
3. Select Add the Vendor role to the selected users from the Action select list.
4. Click Apply to selected items. You should see a message indicating that the desired changes were made.
Attributions
Written by Chris Dart and Jennifer Hodgdon
Prerequisite knowledge
• Section 7.1, “概念:用户,角色和权限”
Site prerequisites
• The Vendor content type must exist, and your site must have at least two Vendor content items. See
Section 6.1, “Adding a Content Type”, Section 6.3, “Adding Basic Fields to a Content Type”, and
Section 5.2, “Creating a Content Item”.
• User accounts for at least two vendors must exist. See Section 7.4, “Creating a User Account”.
Steps
1. In the Manage administrative menu, navigate to Content (admin/content).
2. Find Vendor content item Happy Farm in the list. If it is not immediately visible, you can filter the list
by Published status, Content type (Vendor), Title, or Language. Click Edit for the Vendor content item
you would like to assign an author to.
110
CHAPTER 7. 管理用户账号 7.7. ASSIGNING AUTHORS TO CONTENT
4. Start typing the Vendor’s user name Happy Farm in the Authored by field. The field lists matching user
names. Select the Vendor’s user name from the list.
5. Click Save and keep published.
6. You will get a notification that the Vendor content item has been updated.
7. Follow these steps again to assign Vendor content item Sweet Honey to the Vendor user account Sweet
Honey.
Attributions
Written by Diána Lakatos at Pronovix.
111
Chapter 8
区块
Related topics
• Section 2.1, “Concept: Regions in a Theme”
• Section 8.2, “Creating A Custom Block”
• Section 8.3, “Placing a Block in a Region”
Attributions
Adapted by Les Lim from ”Working with blocks (content in regions)” copyright 2000-2017 by the individual
contributors to the Drupal Community Documentation.
Prerequisite knowledge
• Section 8.1, “Concept: Blocks”
113
CHAPTER 8. 区块 8.2. CREATING A CUSTOM BLOCK
Steps
1. In the Manage administrative menu, navigate to Structure > Block layout > Custom block library (admin/structure/block/
content).
2. Click Add custom block. The Add custom block page appears.
3. Fill in the fields as shown below.
4. Click Save. A message appears indicating the block has been saved.
114
CHAPTER 8. 区块 8.3. PLACING A BLOCK IN A REGION
Additional resources
Drupal.org community documentation page ”Working with blocks (content in regions)”
Attributions
Adapted by Jacob Redding and Boris Doesborg from Working with blocks (content in regions), copyright
2000-2017 by the individual contributors to the Drupal Community Documentation.
Prerequisite knowledge
Section 8.1, “Concept: Blocks”
Site prerequisites
• The core Bartik theme must be installed and set as default. See Section 4.6, “Configuring the Theme”.
• The Opening hours and location block must exist. See Section 8.2, “Creating A Custom Block”.
Steps
1. In the Manage administrative menu, navigate to Structure > Block layout (admin/structure/block). The
Block layout page appears, listing the theme’s regions.
2. Ensure that in the secondary tab the core Bartik theme is selected. Block placement is defined per theme.
3. Locate the region Sidebar second in the list and click Place block next to it. The Place block window
appears, listing all the blocks.
4. Locate the block Opening hours and location and click Place block next to it. The Configure block window
appears. Fill in the fields as shown below.
You can also hide or display the block on specific pages. In the case of the Farmer’s market website you
do not set any of these configuration options because you want to show the block everywhere.
115
CHAPTER 8. 区块 8.3. PLACING A BLOCK IN A REGION
5. Click Save block. The Block layout page appears. You can drag blocks to change the order in which they
will appear.
6. Verify that the Opening hours and location block is listed in the Sidebar second region, and click Save
blocks.
The block has been placed on the sidebar of all pages that use the core Bartik theme.
116
CHAPTER 8. 区块 8.3. PLACING A BLOCK IN A REGION
• If you do not see the effect of these changes in your site, you might need to clear the cache. See Section 12.2,
“Clearing the Cache”.
Attributions
Written and edited by Boris Doesborg and Jennifer Hodgdon.
117
Chapter 9
用视图创建列表
What is a view?
A view is a listing of content on a website. The core Views module handles the display of views, and the core
Views UI module allows you to create and edit them in the administrative interface. When you define views,
you are interested in taking data from your website and displaying it to the user.
119
CHAPTER 9. 用视图创建列表 9.2. 概念:视图的组成
Related topics
• Section 9.2, “概念:视图的组成”
Attributions
Written and edited by Michael Lenahan at erdfisch, and Jojy Alphonso at Red Crackle.
9.2 概念:视图的组成
预备知识
• Section 2.3, “Concept: Content Entities and Fields”
• Section 2.4, “Concept: Modular Content”
• Section 9.1, “Concept: Uses of Views”
• Section 5.1, “Concept: Paths, Aliases, and URLs”
视图由哪些部分组成?
在管理界面中编辑视图时,将会看到以下部分:它们允许您指定输出的数据是什么,输出的顺序是什么,以及
输出的格式是什么:
显示 每个视图可以有一个或多个显示,每个显示可以产生一种类型的输出。显示类型包括:
页面 在一个特定的 URL 输出,并使其成为该 URL 的主要页面内容。
区块 在一个区块中输出,这个区块可以被放置到页面。
订阅源 创建一个 RSS 或者其他类型的订阅源。
附加 让输出可以附加到其他的显示。
格式 取决于显示类型,您可以选择以表格、网格、HTML 列表格式或其他格式显示您的数据。一些格式还给
您一个第二选择,让您选择是输出渲染后的实体还是字段。一些格式则不会给您这种选择(比如,如果
您使用表格格式,您只能使用字段)。
字段 取决于您选择的格式,您可能可以选择输出哪些内容字段。例如,如果您正在制作一个食谱内容条目的
视图,在一个区块显示中,您可能只显示食谱的食谱的名称,而在全文页面,拥有更多的空间,您可能
还会显示一个图像字段。
过滤条件 过滤器限制要输出的数据,基于条件,比如内容是否已发布,内容的类型或字段的值。例如,创建
一个食谱内容的视图,您可能需要过滤出食谱内容类型和已发布的食谱。过滤器还可以提供给用户,这
意味着用户将有一个表单,用户可以自行选择过滤器的值。您可以在一个“食谱”页面,让用户通过指定
的成分过滤出食谱。
排序标准 定义显示输出的顺序,可以基于任何内容字段。
上下文过滤器 上下文过滤器与常规过滤器类似,只是值来自所该视图显示的上下文,例如,页面显示时,页
面的完整 URL,当前日期或时间,或可以通过视图计算来检测到的其他值。
关联 关联允许通过所显示的基本内容与其他的内容实体建立关系,来扩展视图中显示的内容。关联使用涉及
到其他内容的基本内容的字段创建;一个例子是所有常规内容都有作者字段,它引用的是内容作者的账
号。一旦创建了一个关联,您就可以在视图中显示来自其所引用实体中的字段。
120
CHAPTER 9. 用视图创建列表 9.3. CREATING A CONTENT LIST VIEW
相关主题
Section 9.3, “Creating a Content List View”
贡献者
编写:Surendra Mohan 和 Jennifer Hodgdon
翻译:冉强军 @ InterGreat Education Group
Prerequisite knowledge
• Section 9.1, “Concept: Uses of Views”
• Section 9.2, “概念:视图的组成”
Site prerequisites
• The core Views and Views UI modules must be installed. These are installed for you when you install
with the core Standard installation profile.
• The Vendor content type must exist, with URL and Main image fields. Your site must have a couple of
Vendor content items. See Section 6.1, “Adding a Content Type”, Section 6.3, “Adding Basic Fields
to a Content Type”, and Section 5.2, “Creating a Content Item”.
• The Medium (220x220) image style must be defined. This is created on your site when you install the
core Image module (installed with the core Standard installation profile) but can be recreated if deleted.
See Section 6.13, “Setting Up an Image Style”.
Steps
1. In the Manage administrative menu, navigate to Structure > Views > Add view (admin/structure/views/add).
The Add view wizard appears.
2. Fill in the fields as shown below.
121
CHAPTER 9. 用视图创建列表 9.3. CREATING A CONTENT LIST VIEW
122
CHAPTER 9. 用视图创建列表 9.3. CREATING A CONTENT LIST VIEW
4. Click Add from the dropdown button in the Fields section. The Add fields pop-up appears.
123
CHAPTER 9. 用视图创建列表 9.3. CREATING A CONTENT LIST VIEW
16. Click Content: Title (Title) in the Fields list. The Configure field: Content: Title pop-up appears.
17. Uncheck Create a label. This will remove the label that was created by the wizard.
18. Click Apply. The view configuration page appears.
19. Click Rearrange from the dropdown button in the Fields section. The Rearrange fields pop-up appears.
20. Drag the fields into the right order: Image, Title. Body.
21. Click Apply. The view configuration page appears.
22. Optionally, click Update preview for a preview.
124
CHAPTER 9. 用视图创建列表 9.3. CREATING A CONTENT LIST VIEW
24. Navigate to the homepage and click Vendors from the main navigation to see the result.
125
CHAPTER 9. 用视图创建列表 9.4. DUPLICATING A VIEW
Prerequisite knowledge
• Section 9.1, “Concept: Uses of Views”
• Section 9.2, “概念:视图的组成”
• Section 9.3, “Creating a Content List View”
126
CHAPTER 9. 用视图创建列表 9.4. DUPLICATING A VIEW
Site prerequisites
• The Vendor and Recipe content types must exist; both must have Main image fields, and the Recipe
content type must have an Ingredients field. Your site must also have a couple of Recipe content items.
See Section 6.1, “Adding a Content Type”, Section 6.3, “Adding Basic Fields to a Content Type”,
Section 6.6,“Setting Up a Taxonomy”, Section 6.9,“Changing Content Entry Forms”, and Section 5.2,
“Creating a Content Item”.
• The Vendors view must exist. See Section 9.3, “Creating a Content List View”.
Steps
1. In the Manage administrative menu, navigate to Structure > Views (admin/structure/views). Find the
view ”Vendors” and click Duplicate in its dropdown button.
2. Name the duplicate ”Recipes” and click Duplicate. The view configuration page appears.
3. Change the title of the view page to ”Recipes” by clicking Vendors in the Title section. The Page: The
title of this view pop-up appears. Type in ”Recipes”. Click Apply.
127
CHAPTER 9. 用视图创建列表 9.4. DUPLICATING A VIEW
4. Change from a table to a grid format by clicking Table in the Format section. The Page: How should this
view be styled pop-up appears. Check Grid and click Apply. The Page: Style options pop-up appears.
Retain the default values and click Apply.
5. Retain only the title and image fields for the Recipes view by clicking Content: Body in the Fields section.
Click Remove in the pop-up that appears.
6. Change the content type filter to use the Recipe content type by clicking Content: Type (=Vendor) in the
Filter criteria section. In the Configure filter criterion: Content: Type pop-up, check Recipe and uncheck
Vendor. Click Apply.
7. Add a further filter that is exposed to visitors by clicking Add in the Filter criteria section. Search for
”ingredients” and check ”Ingredients (field_ingredients)”. Click Add and configure filter criteria.
8. The appearing pop-up offers extra settings on vocabulary and selection type. Click Apply and continue.
The next pop-up allows you to expose this filter to visitors. Fill in the fields as shown below, and click
Apply.
128
CHAPTER 9. 用视图创建列表 9.4. DUPLICATING A VIEW
9. Change the Path label field to ”Recipes” by clicking ”/vendors” in the Page settings section. In the pop-up
that appears, enter the path ”recipes” and click Apply.
Note that when editing a view, you enter paths without the leading ”/”, unlike on other administrative
pages (such as when providing a path to a content item page).
10. Change the menu link title by clicking ”Normal: Vendors” in the Page settings section. In the pop-up
that appears, change the title to ”Recipes” and click Apply.
129
CHAPTER 9. 用视图创建列表 9.4. DUPLICATING A VIEW
11. In order to use Ajax (see Ajax entry in the Glossary) to make filtering and paging faster for users, click
Advanced to expand the section for more options. In the Other section, change Use AJAX: No to ”Yes”
by clicking No and checking Use AJAX in the pop-up that appears. Click Apply.
12. Click Save to save the view.
13. Go back to the home page and click Recipes in the navigation to view the new Recipes page.
Related concepts
• Section 2.5, “Planning your Content Structure”
• Ajax entry in the Glossary
Attributions
Written and edited by Laura Vass at Pronovix, and Jojy Alphonso at Red Crackle.
130
CHAPTER 9. 用视图创建列表 9.5. ADDING A BLOCK DISPLAY TO A VIEW
Prerequisite knowledge
• Section 9.1, “Concept: Uses of Views”
• Section 9.2, “概念:视图的组成”
• Section 9.3, “Creating a Content List View”
Site prerequisites
• The Recipe content type must exist, it must have a Main image field, and your site must have a couple of
Recipe content items. See Section 6.1, “Adding a Content Type”, Section 6.3, “Adding Basic Fields
to a Content Type”, Section 6.9, “Changing Content Entry Forms”, and Section 5.2, “Creating a
Content Item”.
• The Thumbnail (100x100) image style must be defined. This is created on your site when you install the
core Image module (installed with the core Standard installation profile) but can be recreated if deleted.
See Section 6.13, “Setting Up an Image Style”.
• The Recipes view must exist. See Section 9.3, “Creating a Content List View”and Section 9.4, “Du-
plicating a View”.
Steps
1. In the Manage administrative menu, navigate to Structure > Views (admin/structure/views). Find the
view ”Recipes” and click Edit from its dropdown button. Alternatively, navigate to the Recipes page
in the main site navigation, and click the Edit view contextual link in the main area of the page. See
Section 4.1, “Concept: Administrative Overview”for information about contextual links.
2. Create a new block display by clicking Add in the Displays section. Click Block from the dropdown button.
The new display is created, and the focus is automatically switched to its configuration.
3. Change the title of this display by clicking Block next to Display name. The Block: The name and the
description of this display pop-up appears. Change the Administrative name to ”Recent recipes”. Click
Apply.
131
CHAPTER 9. 用视图创建列表 9.5. ADDING A BLOCK DISPLAY TO A VIEW
4. Change the title of the view by clicking Title: Recipes in the Title section. In the pop-up that appears,
select This block (override) from the For select list. Change the title to ”New recipes” and click Apply
(this display).
5. Change the view’s style by clicking Format: Grid in the Format section. In the pop-up that appears,
select This block (override) from the For select list. Select Unformatted list and Click Apply (this display).
You can further configure the style options in the next pop-up that appears. Then click Apply.
6. Configure the image field by clicking Content: Main image in the Fields section. In the pop-up that
appears, select This block (override) from the For select list. Select Image style Thumbnail (100x100).
Click Apply (this display).
132
CHAPTER 9. 用视图创建列表 9.5. ADDING A BLOCK DISPLAY TO A VIEW
7. Remove ingredients as a filter by clicking Content: Ingredients (exposed) in the Filter criteria section.
In the pop-up that appears, select This block (override) from the For select list. Click Remove at the
bottom.
8. Configure how you want the content to be sorted in the view by clicking Add in the Sort criteria section.
In the pop-up that appears, select This block (override) from the For select list. Check the field Authored
on (from Content category), and then Add and configure sort criteria.
9. In the appearing configuration pop-up, select Sort descending to have the most recent recipes appear first.
Click Apply.
10. Specify the number of items to be displayed by clicking Use pager: Mini in the Pager section. In the
pop-up that appears, select This block (override) from the For select list. Under Pager, select Display a
specified number of items. Click Apply (this display). In the Block: Pager options pop-up, provide ”5” as
the value for Items to display. Click Apply.
11. Click Save. You will either see the view editing page again, or the Recipes page, depending on what you
did in step 1. You should also see a message saying that the view has been saved.
133
CHAPTER 9. 用视图创建列表 9.5. ADDING A BLOCK DISPLAY TO A VIEW
12. Place the ”Recipes: Recent Recipes” block in the Sidebar second region. See Section 8.3, “Placing a
Block in a Region”. Navigate to the site’s home page to see the block.
Attributions
Written and edited by Laura Vass at Pronovix, Jennifer Hodgdon, and Jojy Alphonso at Red Crackle.
134
Chapter 10
多语言
Related topics
• Section 10.2, “Adding a Language”
• Section 10.3, “Configuring Content Translation”
• Section 10.4, “Translating Content”
135
CHAPTER 10. 多语言 10.2. ADDING A LANGUAGE
Prerequisite knowledge
Section 10.1, “Concept: User Interface, Configuration, and Content translation”
Steps
1. Install the four core multilingual modules (Language, Interface Translation, Content Translation, and
Configuration Translation), by following the steps in Section 4.3, “Installing a Module”.
2. In the Manage administrative menu, navigate to Configuration > Regional and language > Languages
(admin/config/regional/language).
3. Click Add language.
4. Select Spanish (or your preferred language) from the Language name select list. Click Add language.
After waiting for translations to finish downloading, you will be returned to the Languages page, with a
confirmation message and the new language shown.
5. Follow the steps in Section 8.3, “Placing a Block in a Region”to place the Language switcher block in
the Sidebar second region. This will enable site visitors to switch between languages, once the site has
been translated.
136
CHAPTER 10. 多语言 10.3. CONFIGURING CONTENT TRANSLATION
Additional resources
Drupal.org page ”Resource Guide: Configuring a Multilingual Site”
Attributions
Written and edited by Leila Tite, Jennifer Hodgdon, and Boris Doesborg.
Prerequisite knowledge
• Section 2.3, “Concept: Content Entities and Fields”
• Section 10.1, “Concept: User Interface, Configuration, and Content translation”
Site prerequisites
The core Content Translation module must be installed, and your site must have at least two languages. See
Section 10.2, “Adding a Language”.
Steps
1. In the Manage administrative menu, navigate to Configuration > Regional and language > Content lan-
guage and translation (admin/config/regional/content-language).
2. Under Custom language settings, check Content, Custom block and Custom menu link to make these entity
types translatable.
137
CHAPTER 10. 多语言 10.3. CONFIGURING CONTENT TRANSLATION
3. Configuration options appear for Content, Custom block and Custom menu link. Choose the subtypes you
want to translate for each entity type. Check Basic page for Content, Basic block for Custom block and
Custom menu link for Custom menu link.
4. Verify the settings for the entity types as shown below:
5. Choose the fields that should be translatable for Basic page as shown in the table below. If a field is not
translation-dependent, leave it unchecked. Enabling translation for fields that are numbers or dates has
use for accountability or implementing workflows.
138
CHAPTER 10. 多语言 10.4. TRANSLATING CONTENT
6. Similarly, check the appropriate boxes for translatable fields belonging to Basic block and Custom menu
link.
7. Click Save configuration.
Additional resources
• Blog post ”Multilingual Drupal 8 tidbits, part 5”
• Blog post ”Multilingual Drupal 8 tidbits, part 17”
Attributions
Written and edited by Laura Vass at Pronovix, Jojy Alphonso at Red Crackle, and Jennifer Hodgdon.
Prerequisite knowledge
Section 10.1, “Concept: User Interface, Configuration, and Content translation”
Site prerequisites
• The Home content item must exist. See Section 5.2, “Creating a Content Item”.
• The core Content Translation module must be installed, and your site must have at least two languages.
See Section 10.2, “Adding a Language”.
• The Basic page content type must be configured to be translatable. See Section 10.3, “Configuring
Content Translation”.
139
CHAPTER 10. 多语言 10.4. TRANSLATING CONTENT
Steps
1. In the Manage administrative menu, navigate to Content (admin/content).
2. Locate the home page. You can search for it by entering ”Home” in the title field.
3. Select Translate from the dropdown button in the row of the Home content item. The page Translations
of Home appears.
4. Click Add in the row Spanish.
5. Note that the user interface has switched to Spanish. To switch it back to English, remove the first instance
of es in the browser’s URL. For example, if your URL looks like example.com/es/node/5/translations/add/en/es,
remove the es that comes immediately after example.com.
6. Fill in the fields as shown below. You will have to click and expand URL path settings on the right to
provide the value for URL alias.
Attributions
Written by Boris Doesborg.
140
CHAPTER 10. 多语言 10.5. TRANSLATING CONFIGURATION
Prerequisite knowledge
• Section 10.1, “Concept: User Interface, Configuration, and Content translation”
• Section 9.3, “Creating a Content List View”
Site prerequisites
• The core Configuration Translation module must be installed, and your site must have at least two
languages. See Section 10.2, “Adding a Language”.
• The Recipes view must exist. See Section 9.3, “Creating a Content List View”and Section 9.4, “Du-
plicating a View”.
Steps
The basic steps for translating any configuration on your site are:
1. Locate the page where the configuration you want to translate is created or edited in the site’s primary
language. For example, to translate the site name, you need to find the page where you would edit the
site name (see Section 4.2, “Editing Basic Site Information”).
2. Find a link, tab, or button on the page that says ”Translate” or something similar. Click this link, tab,
or button.
3. Find a button that will let you add a translation in the desired language, and click this button.
4. Enter the translation in the form, and save.
Most configuration is fairly straightforward and intuitive to edit in this manner. Views configuration is an
exception, because the translation editing form is nothing like the view editing form, and it is complex and
hierarchical rather than being a simple form with just a few fields. As an example of how to translate a view,
here are the steps to translate the labels in the Recipes view to Spanish:
1. In the Manage administrative menu, navigate to Structure > Views (admin/structure/views).
2. Locate the Recipes view and click Translate from the dropdown button.
3. Click Add in the row Spanish. The page Add Spanish translation for Recipes view appears.
4. Find Displays > Master Display settings > Recipes default display Options. Translate the Display title
from ”Recipes” to ”Recetas”.
5. Find Displays > Master display settings > Recipes default display options > Exposed form > Reset options.
Translate Submit button text (Apply) to ”Applicar”. The other buttons and labels in this section do not
appear on the Recipes page or block, and do not need to be translated.
141
CHAPTER 10. 多语言 10.5. TRANSLATING CONFIGURATION
6. Find Displays > Master display settings > Recipes default display options > Filters > (Empty) taxonomy
term ID > Find recipes using…Expose. In the Label field, enter ”Encontrar recetas usando…”.
7. Click Save translation.
8. Navigate to the Recipes page and switch to Spanish using the Language switcher block. Verify that the
labels have been translated.
– To translate the site name, navigate in the Manage administrative menu to Configuration > System >
Basic site settings > Translate system information (admin/config/system/site-information/translate).
– To translate the contact form, navigate in the Manage administrative menu to Structure > Contact
forms (admin/structure/contact). Click Translate in the dropdown button in the Website feedback
row.
142
CHAPTER 10. 多语言 10.5. TRANSLATING CONFIGURATION
– To translate the name of a menu, navigate in the Manage administrative menu to Structure > Menus
(admin/structure/menu). Click Translate in the dropdown button for the menu whose name you
want to translate.
– Menu items within a menu are considered to be content (not configuration); see Section 10.3,“Con-
figuring Content Translation”to enable translation. Once translation is enabled, navigate in the
Manage administrative menu to Structure > Menus (admin/structure/menu). Click Edit menu in
the dropdown button for the menu whose links you want to translate. Click Translate in the dropdown
button for the link you want to translate.
– To translate field labels on a content type, navigate in the Manage administrative menu to Structure
> Content types (admin/structure/types). Click Manage fields in the dropdown button for the content
type whose field labels you want to edit. Click Translate in the dropdown button for the field whose
label you want to edit.
Attributions
Written and edited by Boris Doesborg and Jennifer Hodgdon.
143
Chapter 11
扩展和自定义网站
Prerequisite knowledge
• Section 1.1, “概念:Drupal 作为一个内容管理系统”
• Section 1.2, “概念:模块”
Steps
1. Go to Drupal.org, and navigate to Download & Extend > Modules (https://www.drupal.org/project/-
project_module).
2. Filter your search using the categories on the module search page. Fill in the fields as shown below.
145
CHAPTER 11. 扩展和自定义网站 11.1. FINDING MODULES
146
CHAPTER 11. 扩展和自定义网站 11.1. FINDING MODULES
147
CHAPTER 11. 扩展和自定义网站 11.1. FINDING MODULES
4. To further evaluate a module, click its title in the list of search results to visit its project page.
148
CHAPTER 11. 扩展和自定义网站 11.2. ENABLING AND DISABLING …
Prerequisite knowledge
Section 13.3, “Concept: Security and Regular Updates”
Steps
Enabling maintenance mode
1. In the Manage administrative menu, navigate to Configuration > Development > Maintenance mode
(admin/config/development/maintenance). The Maintenance mode page appears.
2. Fill in the fields as shown below.
149
CHAPTER 11. 扩展和自定义网站 11.2. ENABLING AND DISABLING …
150
CHAPTER 11. 扩展和自定义网站 11.2. ENABLING AND DISABLING …
4. Verify that the site is no longer in maintenance mode by accessing it from another browser where you
aren’t logged in. If you are not able to verify, try clearing the cache. See Section 12.2, “Clearing the
Cache”.
Attributions
Written and edited by Boris Doesborg, and Jojy Alphonso at Red Crackle.
151
CHAPTER 11. 扩展和自定义网站 11.3. DOWNLOADING AND INSTALLING A …
Prerequisite knowledge
• Section 1.2, “概念:模块”
• Section 11.1, “Finding Modules”
• Section 3.2, “Concept: Additional Tools”
Site prerequisites
• If you want to install modules via the website, the core Update Manager module must be installed. See
Section 4.3, “Installing a Module”for instructions on installing modules.
• If you want to use Drush, Drush must be installed. See Section 3.2, “Concept: Additional Tools”.
Steps
You can use the administrative interface or Drush to install a contributed module. If you are installing a
custom module rather than a contributed module, if you see a message saying Installing modules and themes
requires FTP access to your server, or if the steps below do not work to download and unpack the module files,
follow the steps in Section 11.6, “Manually Downloading Module or Theme Files”. If you are installing a
contributed module with external dependencies that are managed by Composer, follow the steps for downloading
in Section 11.9, “Using Composer and Git to Download Files”. In either of these cases, then continue here
with step 7 in the instructions for the administrative interface below.
3. In the Manage administrative menu, navigate to Extend (admin/modules). The Extend page appears.
152
CHAPTER 11. 扩展和自定义网站 11.3. DOWNLOADING AND INSTALLING A …
4. Click Install new module. The Install new module page appears.
5. In the field Install from a URL, paste the copied download link. This value could look like this:
https://ftp.drupal.org/files/projects/admin_toolbar-8.x-1.14.tar.gz
6. Click Install to upload and unpack the new module on the server. The files are being downloaded to the
modules directory.
7. Click Enable newly added modules to return to the Extend page. If you used the manual uploading
procedure, start with this step, and reach the Extend page by using the Manage administrative menu and
navigating to Extend (admin/modules).
8. Locate and check Admin toolbar.
Using Drush
1. Find the project name for the module you want to install, which is the last segment of the module’s
project page URL. For example, if the project URL is https://www.drupal.org/project/admin_toolbar, the
project name is ”admin_toolbar”.
2. Run the following Drush commands, giving the project name (for example, admin_toolbar) as a param-
eter:
153
CHAPTER 11. 扩展和自定义网站 11.4. FINDING THEMES
drush dl admin_toolbar
drush en admin_toolbar
• If you do not see the effect of these changes in your site, you might need to clear the cache. See Section 12.2,
“Clearing the Cache”.
Additional resources
• Drupal.org community documentation page ”Contributed modules”
• ”Download and Extend” page on Drupal.org
• Admin Toolbar module on Drupal.org
Attributions
Written and edited by Boris Doesborg and Jennifer Hodgdon.
Prerequisite knowledge
• Section 1.1, “概念:Drupal 作为一个内容管理系统”
Steps
1. Go to https://www.drupal.org, and navigate to Download & Extend > Themes (https://www.drupal.org/-
project/project_theme).
2. Filter your search using the categories on the theme search page. For example, you might use these filters:
154
CHAPTER 11. 扩展和自定义网站 11.4. FINDING THEMES
155
CHAPTER 11. 扩展和自定义网站 11.4. FINDING THEMES
156
CHAPTER 11. 扩展和自定义网站 11.5. DOWNLOADING AND INSTALLING A …
4. To further evaluate a theme, click its title in the list of search results to visit its project page.
Attributions
Written by Diána Lakatos.
Prerequisite knowledge
• Section 11.4, “Finding Themes”
• Section 3.2, “Concept: Additional Tools”
Site prerequisites
If you want to install via the website, the core Update Manager module must be installed. See Section 4.3,
“Installing a Module”for instructions on installing modules.
If you want to use Drush, Drush must be installed. See Section 3.2, “Concept: Additional Tools”.
Steps
You can use the administrative interface or Drush to install a contributed theme. If you are installing a custom
theme rather than a contributed theme, if you see a message saying Installing modules and themes requires FTP
access to your server, or if the steps below do not work to download and unpack the theme files, follow the steps
in Section 11.6, “Manually Downloading Module or Theme Files”. If you are installing a contributed theme
with external dependencies that are managed by Composer, follow the steps for downloading in Section 11.9,
“Using Composer and Git to Download Files”. In either of these cases, then continue here with step 7 in the
instructions for the administrative interface below.
157
CHAPTER 11. 扩展和自定义网站 11.5. DOWNLOADING AND INSTALLING A …
3. In the Manage administrative menu, navigate to Appearance (admin/appearance). The Appearance page
appears.
4. Click Install new theme. The Install new theme page appears.
158
CHAPTER 11. 扩展和自定义网站 11.5. DOWNLOADING AND INSTALLING A …
5. In the field Install from a URL, paste the copied download link. This value could look like https://ftp.drupal.org/fil
6. Click Install to upload and unpack the new theme on the server. The files are being downloaded to the
themes directory.
7. Click Install newly added themes to return to the Appearance page. If you used the manual uploading
procedure, start with this step, and reach the Appearance page by using the Manage administrative menu
and navigating to Appearance (admin/appearance).
8. Locate the new theme under Uninstalled themes and click Install and set as default to use it. All non-
administrative pages on the site will now use this new theme.
159
CHAPTER 11. 扩展和自定义网站 11.6. MANUALLY DOWNLOADING MODULE …
Using Drush
1. Find the project name for the theme you want to install, which is the last segment of the theme’s project
page URL. For example, if the project URL is https://www.drupal.org/project/mayo, the project name is
mayo.
2. Run the following Drush commands, giving the project name (for example, mayo) as a parameter:
drush dl mayo
drush en mayo
drush config -set system . theme default mayo
160
CHAPTER 11. 扩展和自定义网站 11.6. MANUALLY DOWNLOADING MODULE …
Prerequisite knowledge
• Section 1.2, “概念:模块”
Site prerequisites
You need to be facing any of the following to perform the manual download described in this topic:
• File permission issues
Steps
If you are installing a module or theme from Drupal.org, follow the downloading instructions, and then the up-
loading/unpacking instructions. If you created the module or theme, skip the downloading step. Instead, create
an archive file (that you know how to extract on the server) and proceed with the steps in uploading/unpacking,
using whatever method is appropriate for the way you initially created the archive file.
161
CHAPTER 11. 扩展和自定义网站 11.6. MANUALLY DOWNLOADING MODULE …
2. If you are replacing an existing module or theme with an updated version, put the site into maintenance
mode. See Section 11.2, “Enabling and Disabling Maintenance Mode”.
3. If you are replacing an existing module or theme with an updated version, find and delete all the existing
files and directories for the existing module or theme. Modules are normally located in directories under
the top-level modules directory, and themes are normally located in directories under the top-level themes
directory.
4. Upload the .tar.gz file (or whatever archive you created) to your site. Place it in either the same loca-
tion from which you deleted the directory (if replacing an existing module or theme) or the appropriate
subdirectory of modules or themes (if adding a new module or theme).
5. Extract the files from the .tar.gz archive (or whatever archive you created), making a subdirectory in
the same location as the archive file. If you do not have terminal access, or your hosting server is not
running Linux, your hosting control panel’s file manager should provide a way to extract the files. If you
have terminal access to your hosting server (running Linux) and you are using a tar.gz file, you can use a
command like:
tar -xzf admin_toolbar -8.x -1.17. tar.gz
6. Delete the compressed file from the server, unless your unpacking method already deleted it.
7. Refer to Section 11.3, “Downloading and Installing a Module from Drupal.org”, Section 11.5, “Down-
loading and Installing a Theme from Drupal.org”, Section 13.6, “Updating a Module”, or Section 13.7,
“Updating a Theme”to complete the installation or update of the module or theme. Start at the step
after the automatic download has been completed.
Additional resources
• Drupal.org community documentation page ”Updating modules”
• Drupal.org community documentation page ”Installing contributed modules (Drupal 8)”
Attributions
Written and edited by Boris Doesborg, Jennifer Hodgdon, and Marc Isaacson.
162
CHAPTER 11. 扩展和自定义网站 11.7. CONCEPT: DEVELOPMENT SITES
Local environment The development process starts with developers working on new features, bug fixes,
theming, and configuration in their local environment.
Development site Developers push the changes they’ve been working on to the development site. For a
team of more than one developer, version control is usually used. Git is a version control system that
tracks your files for any changes. You can then commit those changes to a repository. Using Git allows
team members to work on the same site without overriding each other’s work. It also makes it possible
to easily roll back to previous stages of the development.
Staging site The staging site can be used for testing, or presenting the changes to the client for approval.
QA (Quality Assurance) and UAT (User Acceptance Testing) are most often carried out on the staging
site. It is recommended to have live content on both the development and staging sites, so that you can
test how the new features will work with the existing content.
Production site The live site on the web available to visitors. It contains new features that have been
proven safe to go live.
Based on the project’s size, scope, requirements, or stakeholders, stages from the above workflow can be
removed, or additional stages can be added. For example, a testing site before staging can be added to separate
testing and user acceptance processes.
Related topics
• Section 11.8, “Making a Development Site”
Additional resources
Drupal.org community documentation page ”Introduction to Git”
Attributions
Written and edited by Diána Lakatos, and Jojy Alphonso at Red Crackle.
Prerequisite knowledge
Section 11.7, “Concept: Development Sites”
Site prerequisites
• You have a live, developed site that you would like to make a copy of for development purposes.
• If you want to use Drush for some of the steps in this task, Drush must be installed. See Section 3.2,
“Concept: Additional Tools”.
163
CHAPTER 11. 扩展和自定义网站 11.8. MAKING A DEVELOPMENT SITE
Steps
1. Follow the steps in Section 3.3,“Preparing to Install”, so that you have hosting set up for your development
site, you know where the web root is for your development site, and you have an empty database and
database user for your development site to use.
2. Make a database dump file from your live site’s database. Try one of the following methods:
• If you are using MySQL as your database, and your live site’s server has phpMyAdmin installed
(it is available from many hosting control panels), use the Export tab in phpMyAdmin to export in
SQL format. Using gzip compression on the output file is suggested, to reduce the file size.
• If you are using MySQL and have access to the command line, use this command (substituting in
your site’s database name, user name, and password):
mysqldump -u USERNAME -p'PASSWORD ' DATABASENAME > BACKUPFILE .sql
• Use the contributed Backup and Migrate module from within your live site. See Section 11.3,
“Downloading and Installing a Module from Drupal.org”for instructions on installing contributed
modules.
You now have a database dump stored in the file BACKUPFILE.sql. For security reasons, avoid
storing this file on your hosting server anywhere under the Drupal site root. This will prevent others
from getting a copy of your database.
3. Copy all of the files from the web root of your live site to the web root of your development site.
4. Edit the sites/default/settings.php file under your development site’s top-level directory in a plain-text
editor. Find the lines near the end that contain the database name, database username, and database
password, and update them to the information about the development site database you set up. The lines
look something like this (before editing):
$databases ['default '][' default '] = array (
'database ' => 'live_site_database_name ',
'username ' => 'live_site_database_username ',
'password ' => 'live_site_database_password ',
5. Check whether your settings.php file has the following setting; if yes, then you will need to edit this to
point to your development site URL instead of your production site URL:
$settings [' trusted_host_patterns ']
6. Import the database dump file you created, into the development site’s database. Try one of the following
methods:
• If you are using MySQL as your database, and your live site’s server has PHPMyAdmin installed
(it is available from many hosting control panels), use the Import tab in PHPMyAdmin. You may
find that you have to restart the import a few times, if your database was large.
• If you are using MySQL and have access to the command line, use this command (substituting in
your site’s database name, user name, and password; if you made a gzip-compressed backup file,
you will also need to uncompress it first):
mysql -u USERNAME -pPASSWORD DATABASE_NAME < BACKUPFILE .sql
164
CHAPTER 11. 扩展和自定义网站 11.9. USING COMPOSER AND GIT TO …
7. If your development and live sites need to have different configuration, then you have to use configuration
overrides in the settings.php file. The $config variable will help you maintain override values separately
from the standard configuration data. For instance, you might want the site name to be ”Anytown Farmers
Market” on the production site, but ”Development Site for Anytown Farmers Market” on the development
site. To do that, you could have the production value in the site configuration (in the database), and on
the development site, in the settings.php file, you would need to have:
$config [' system .site '][' name '] = " Development Site for Anytown Farmers Market ";
Additional resources
• Drupal.org community documentation page ”Backing up a site”
• Drupal.org community documentation page ”Create a Test Site”
Attributions
Written and edited by Jennifer Hodgdon, Joe Shindelar at Drupalize.Me, and Jojy Alphonso at Red Crackle.
Prerequisite knowledge
• Section 3.2, “Concept: Additional Tools”
• Section 11.7, “Concept: Development Sites”
Site prerequisites
If you want to use Git or Composer, they must be installed either on a local development server or your live
site. See Section 3.2, “Concept: Additional Tools”.
Steps
If you are unable to install the Git or Composer tools on your live server, after following the steps in any of the
sections below on your local server, you will need to transfer any updated or added files to your live server. The
recommended procedure is to make an archive or zip file of the new and changed files, transfer the archive to
your live server, and extract it there. If you are using Composer, make sure to check for updates and additions
to the following files, in the root of your installation:
• vendor directory
• autoload.php
• composer.json
• composer.lock
165
CHAPTER 11. 扩展和自定义网站 11.9. USING COMPOSER AND GIT TO …
5. This will create a directory named with the short name of the project (drupal in this example), and
download the required files into that directory. If necessary, rename the directory.
6. If you downloaded the drupal project (the core software), follow the instructions below to download its
external dependencies.
7. Later on, you can change to the created directory and run the command git pull to update the files to
the latest version from the Git repository for the project.
166
CHAPTER 11. 扩展和自定义网站 11.10. DEPLOYING NEW SITE FEATURES
2. If you have not already done so, you can optionally override the default location where Composer will put
downloaded modules and themes. For example, typically you would want contributed modules to go in
a contrib subdirectory of the top-level modules directory, instead of the default location of modules. To
make this change, edit the composer.json file at the root level in your site installation. Find the line that
says "extra": {, and add these lines following that line:
"installer -paths ": {
" modules / contrib /{ $name }": [" type:drupal - module "],
" modules / custom /{ $name }": [" type:drupal -custom - module "],
" profiles / contrib /{ $name }": [" type:drupal - profile "],
" themes / contrib /{ $name }": [" type:drupal - theme "],
" themes / custom /{ $name }": [" type:drupal -custom - theme "],
" libraries /{ $name }": [" type:drupal - library "],
"drush /{ $name }": [" type:drupal -drush "]
},
3. Each time you want to add a contributed module or theme, determine the project’s short name. This is the
last part of the URL of the project page; for example, the Geofield module, at https://www.drupal.org/-
project/geofield, has short name geofield.
4. To download the contributed module or theme, along with its external dependencies, enter the following
command at the root of your site (substituting the short name of the module or theme for geofield):
composer require drupal / geofield
3. Enter the following command at the root of your site (substituting the short name of the module or theme
for geofield and the correct version number):
composer require drupal / geofield :1.7
Additional resources
Drupal.org community documentation page ”Using Composer with Drupal”
Attributions
Adapted by Jennifer Hodgdon from ”Using Composer with Drupal”, copyright 2000-2017 by the individual
contributors to the Drupal Community Documentation.
167
CHAPTER 11. 扩展和自定义网站 11.10. DEPLOYING NEW SITE FEATURES
Prerequisite knowledge
• Section 11.8, “Making a Development Site”
Site prerequisites
• The core Configuration Manager module must be installed in both the development and production sites.
See Section 4.3, “Installing a Module”for instructions on installing core modules.
• The Vendor content type must exist in both the development and production sites, with the same fields.
See Section 6.1, “Adding a Content Type”.
• The Vendors view must exist in the development site but not the production site. See Section 9.3,
“Creating a Content List View”.
Steps
1. Open the local development site.
2. In the Manage administrative menu, navigate to Configuration > Development > Configuration synchro-
nization > Export > Single item (admin/config/development/configuration/single/export). The Single
export page appears.
168
CHAPTER 11. 扩展和自定义网站 11.10. DEPLOYING NEW SITE FEATURES
169
CHAPTER 11. 扩展和自定义网站 11.11. SYNCHRONIZING CONFIGURATION …
Related concepts
• Section 11.7, “Concept: Development Sites”
Attributions
Written by Boris Doesborg.
Prerequisite knowledge
• Section 1.5, “Concept: Types of Data”
• Section 3.3, “Preparing to Install”
• Section 11.7, “Concept: Development Sites”
• Section 11.8, “Making a Development Site”
Site prerequisites
• You must have a development copy of your production site. See Section 11.8, “Making a Development
Site”.
• The core Configuration Manager module must be installed on both the development and production sites.
See Section 4.3, “Installing a Module”for instructions on how to install core modules.
• You must have changed configuration on either the production or development site (the source site), and
want to synchronize the changes to the other site (the destination site). As an example, you can develop a
new content type, fields, and views on your development site, and when it is all working correctly, deploy
the changes to the live site.
• All configuration that should not be synchronized between the source and destination sites must be stored
in configuration overrides in the settings.php file rather than in the database. See Section 11.8, “Making
a Development Site”.
170
CHAPTER 11. 扩展和自定义网站 11.11. SYNCHRONIZING CONFIGURATION …
Steps
1. In the source site, in the Manage administrative menu, navigate to Configuration > Development >
Configuration synchronization > Export (admin/config/development/configuration/full/export).
2. Click Export. Your site will generate an archive of the full site configuration. Save the file on your local
computer.
3. In the destination site, in the Manage administrative menu, navigate to Configuration > Development >
Configuration synchronization > Import (admin/config/development/configuration/full/import).
4. Browse to find the downloaded configuration archive, and click Upload. Your configuration archive will
be uploaded to the destination site, and you will be redirected to the configuration Synchronize page
(admin/config/development/configuration) with a message saying your files were uploaded.
5. Verify that the differences shown on the page are what you expect. You may see configuration items that
have been added, deleted, or changed; for changed items, you can click View differences to see what the
changes are.
6. When you are satisfied, click Import all to import the configuration changes.
Attributions
Written by Jennifer Hodgdon.
171
Chapter 12
防止和修复问题
• Old data remaining in the cache too long, leading to outdated page output
• Insufficient caching, leading to slow page loads
173
CHAPTER 12. 防止和修复问题 12.2. CLEARING THE CACHE
• The system locates certain low-level PHP functions and classes, such as hook implementations and plugin
classes, from your installed modules and stores information about which module has which functionality.
If you are developing a new module or adding features to an existing module, you may need to clear this
cache to have your new features be recognized.
Related topics
If you have problems with your site, the first thing to try to fix it is usually to clear the cache. See Section 12.2,
“Clearing the Cache”for more information.
Additional resources
Learn about additional caching and performance optimization methods in the Drupal.org community documen-
tation page ”Caching to improve performance”.
Attributions
Written by Jennifer Hodgdon.
Prerequisite knowledge
• Section 12.1, “Concept: Cache”
Site prerequisites
If you want to use Drush to clear the cache, Drush must be installed. See Section 3.2, “Concept: Additional
Tools”.
Steps
You can use the administrative interface or Drush to clear the cache.
3. A message saying the cache has been cleared appears at the top of the page.
Using Drush
You can use one of two commands:
• Use the command drush cache-rebuild to clear and rebuild all cached data for a site. After running
this command, you will see the output message ”Cache rebuild complete.”
• Use the command drush cc to see a list of individual caches and then choose the specific cache you would
like to clear. Running this command should produce output like the following:
174
CHAPTER 12. 防止和修复问题 12.3. CONCEPT: DATA BACKUPS
> drush cc
Enter a number to choose which cache to clear.
[0] : Cancel
[1] : drush
[2] : theme - registry
[3] : menu
[4] : css -js
[5] : block
[6] : module -list
[7] : theme -list
[8] : render
[9] : views
Choose a cache to clear by entering the number associated with that cache. Press ”Enter” to continue.
Additional resources
Drupal.org community documentation page ”Clearing or rebuilding Drupal’s cache”
Attributions
Adapted and edited by Joe Shindelar and Jack Haas from ”Clearing or rebuilding Drupal’s cache”, copyright
2000-2017 by the individual contributors to the Drupal Community Documentation.
175
CHAPTER 12. 防止和修复问题 12.4. CONCEPT: LOG
• Modules, themes and any other software files you have customized. You can find customized modules and
themes in the modules and themes directories respectively. Some people prefer to back up all software
files, including core files and contributed modules and themes (which you could recover by downloading
them again from the source), rather than trying to pick out specific files that definitely need to be backed
up.
You can perform a test to confirm whether your backup has been done right by making a development copy
of the site (see Section 11.8, “Making a Development Site”).
Related topics
• Section 13.5, “Updating the Core Software”
Additional resources
• Drupal.org community documentation page ”Backing up a site”
• The contributed Backup and Migrate module, which can be used to set up automatic backups of the
database and uploaded files.
Attributions
Written by Jennifer Hodgdon.
176
CHAPTER 12. 防止和修复问题 12.5. CONCEPT: STATUS REPORT
Attributions
Adapted by Diána Lakatos from ”Reports” copyright 2000-2017 by the individual contributors to the Drupal
Community Documentation
177
CHAPTER 12. 防止和修复问题 12.5. CONCEPT: STATUS REPORT
Related topics
Section 14.2, “Getting Support”
Attributions
Adapted by Diána Lakatos from ”Reports” copyright 2000-2017 by the individual contributors to the Drupal
Community Documentation
178
Chapter 13
安全和维护
What is the relationship between the site’s cron tasks and Unix cron?
Linux/Unix-based operating systems have a cron scheduler that can be used to run periodic tasks. You can
use the server’s cron scheduler to schedule runs of the site’s cron tasks. Alternatively, you can use the core
Automated Cron module to run tasks. You can check the site’s cron tasks’ status in the status report.
Related topics
• Section 13.2, “Configuring Cron Maintenance Tasks”
• Section 12.5, “Concept: Status Report”
Additional resources
Drupal.org community documentation page ”Setting up cron”
Attributions
Written and edited by Diána Lakatos at Pronovix, Dave Hansen-Lange at Advomatic, and Boris Doesborg.
Prerequisite knowledge
Section 13.1, “Concept: Cron”
179
CHAPTER 13. 安全和维护 13.2. CONFIGURING CRON MAINTENANCE …
Steps
1. Review the Status report (see Section 12.5, “Concept: Status Report”) to see when cron maintenance
tasks were last run.
If you installed the website using the core Standard installation profile (or similar), then cron maintenance
tasks might already be running via the core Automated Cron module. By default, these tasks are run
about every three hours.
2. Choose whether to run cron maintenance tasks using the core Automated Cron module, or by other means.
The core Automated Cron module might not be suitable for some websites because:
• Each time someone accesses a page on the site, the module checks how long it has been since cron
maintenance tasks have last run, and then runs them if necessary. If no one visits the website for a
long time, cron maintenance tasks will not be run.
• Cron maintenance tasks are run after the page has been generated. This means there is less time for
the tasks to be run before various server timeouts are reached (for example, PHP execution timeout).
If this happens, the logs (see Section 12.4, “Concept: Log”) will show error messages that cron is
unable to complete.
• There is a small scalability cost associated with the core Automated Cron module. This is because
one of the web server’s processes is occupied (and can’t serve other web pages) until the cron
maintenance tasks are complete.
3. If you want to use the core Automated Cron module, first make sure it is installed (it is installed with the
core Standard install profile; see Section 4.3, “Installing a Module”if it is not installed).
Next, configure the module to control how frequently cron maintenance tasks are run. In the Manage
administrative menu, navigate to Configuration > System > Cron (admin/config/system/cron). Choose
the desired interval in the Cron settings section, and click Save configuration.
4. If you want to run cron maintenance tasks from outside the website, uninstall the core Automated Cron
module (see Section 4.4,“Uninstalling Unused Modules”). Next, find the cron URL. This URL is shown in
the Status report (see Section 12.5,“Concept: Status Report”), and in the Cron administration page (see
previous step). The URL looks like this: http://www.example.com/cron/0MgWtfB33FYbbQ5UAC3L0LL3RC0PT3RNU
180
CHAPTER 13. 安全和维护 13.3. CONCEPT: SECURITY AND REGULAR …
Whenever this URL is visited, cron maintenance tasks will run. Set up one of the following schedulers to
access this URL regularly:
Related concepts
Section 13.3, “Concept: Security and Regular Updates”
Additional resources
• Drush page ”Running Drupal cron tasks from Drush”
Attributions
Written and edited by Dave Hansen-Lange at Advomatic, Boris Doesborg, and Jennifer Hodgdon.
181
CHAPTER 13. 安全和维护 13.4. KEEPING TRACK OF UPDATES
Related topics
• Section 13.4, “Keeping Track of Updates”
• Section 13.5, “Updating the Core Software”
• Section 13.6, “Updating a Module”
Additional resources
• Drupal.org community documentation page ”Securing your site”
• ”Security advisories” on Drupal.org
• Drupal.org Security team
Attributions
Written and edited by Boris Doesborg and Jennifer Hodgdon.
Prerequisite knowledge
Section 13.3, “Concept: Security and Regular Updates”
Steps
There are a few different ways to receive notifications of security releases:
• In the Manage administrative menu, navigate to Reports > Available updates > Settings. Enter the email
addresses to be notified when updates are available. You can also specify whether you want daily or
weekly updates. Click Save configuration.
• Subscribe to the security announcements email list. To subscribe, log in to Drupal.org, go to your user
profile page and subscribe to the security newsletter on the Edit > My newsletters tab.
182
CHAPTER 13. 安全和维护 13.5. UPDATING THE CORE SOFTWARE
Related concepts
• Section 13.3, “Concept: Security and Regular Updates”
Additional resources
• ”Security advisories” on Drupal.org
• Drupal.org Security Team
• @drupalsecurity on Twitter
Attributions
Written by Sarah German at Advomatic.
Site prerequisites
• If you want to use Drush, Drush must be installed. See Section 3.2, “Concept: Additional Tools”.
• If your site is live, you should test this process in a development environment before running it on your
production site. See Section 11.8, “Making a Development Site”.
Steps
1. Make a complete backup of your site. Refer to Section 12.3, “Concept: Data Backups”.
2. Open settings.php (/sites/default/settings.php) in any plain text editor. Find the line with the $set-
tings[update_free_access] variable. By default, it is set to ”FALSE” due to security reasons. Change the
setting to ”TRUE”:
$settings [' update_free_access '] = TRUE;
3. Disable any caching technique (memcache, varnish, and so on) your application might be using.
4. Put your site in maintenance mode. See Section 11.2, “Enabling and Disabling Maintenance Mode”.
5. If you are using Composer to manage dependencies, or using Git, skip the next six steps, and instead see
Section 11.9, “Using Composer and Git to Download Files”for instructions on downloading updated
files. Continue with the update.php step.
6. Download the tar.gz or zip file archive for the latest version of Drupal 8.x core from Drupal.org Drupal
Core Downloads. See Section 3.3,“Preparing to Install”for more details on how to find the latest version.
7. Upload the archive file to your web hosting server.
8. Extract the archive file to a temporary directory on your server (should be outside the directory where
the site is hosted). Your hosting control panel’s file manager should provide a way to extract the files.
Or, if you have terminal access to your hosting server (running Linux), you can use a command like:
183
CHAPTER 13. 安全和维护 13.5. UPDATING THE CORE SOFTWARE
9. You can also use Drush to download the archive and extract it in one step, by navigating to the temporary
directory on the server and entering this command:
drush dl drupal
10. In your site hosting directory, delete the core and vendor directories, and all files that are not in a
subdirectory, including .htaccess, composer.json, and autoload.php. Don’t delete custom and customized
files because you may end up losing the custom functionality stored in them.
11. Copy the core and vendor directories and the non-custom/non-customized files that you deleted in the
preceding step from the temporary directory to your site directory.
12. Run the update.php script using either of the following:
• Visit http://www.example.com/update.php in your browser (where www.example.com is your site’s
URL). Click Continue in the first screen to run the updates and successfully complete the script.
• Run the following Drush command: drush updb
13. If you get any error or warning, re-run the update.php script again till all the updates have been completed
successfully.
14. Open settings.php (/sites/default/settings.php) in a text editor. Find the line with the $settings[update_free_access]
variable and update it to ”FALSE”:
$settings [' update_free_access '] = FALSE;
15. Click Administration pages to return to the administration section of your site.
16. Take your site out of maintenance mode. See Section 11.2, “Enabling and Disabling Maintenance Mode”
.
17. Clear the cache. See Section 12.2, “Clearing the Cache”.
18. Re-enable any caching technique you disabled at Step 3.
19. You should have the updated version running. You can verify the current version of your software by
checking the Status report (see Section 12.5, “Concept: Status Report”).
Related concepts
Section 12.5, “Concept: Status Report”
Additional resources
• ”Drupal Core Downloads” page on Drupal.org
• ”Registry Rebuild” page on Drupal.org
• The file /core/UPDATE.txt within your installation.
Attributions
Written and edited by Surendra Mohan, Boris Doesborgh, and Jojy Alphonso at Red Crackle.
184
CHAPTER 13. 安全和维护 13.6. UPDATING A MODULE
Prerequisite knowledge
• Section 13.3, “Concept: Security and Regular Updates”
• Section 13.1, “Concept: Cron”
Site prerequisites
• A contributed module has been installed and there is an update available for it. See Section 11.3,“Down-
loading and Installing a Module from Drupal.org”and Section 13.4, “Keeping Track of Updates”.
• If your site is live, you should test this process in a development environment before running it on your
production site. See Section 11.8, “Making a Development Site”.
• You have created a full-site backup. See Section 12.3, “Concept: Data Backups”.
• If you want to use the user interface, the core Update Manager module must be installed. See Section 4.3,
“Installing a Module”for instructions on installing core modules.
• If you want to use Drush, Drush must be installed. See Section 3.2, “Concept: Additional Tools”.
Steps
Before you start, check for module-specific update instructions. This is typically necessary while updating
modules that involve the usage of third-party libraries. Read and understand all module-specific requirements
before proceeding with the updates. To find instructions, check the module’s project page Read Documentation
link.
To view further instructions, download the tar.gz or .zip file from the project page to your local computer.
Unzip the file and look for README.txt, INSTALL.txt, and UPGRADE.txt that come with the module’s
installation file. Also, review the release notes on the project page by clicking the version number you’re
downloading.
You can use the administrative interface or Drush to update a contributed module. If you are updating a
custom module rather than a contributed module, if you see a message saying Installing modules and themes
requires FTP access to your server, or if the steps below do not work to obtain the new module files, follow the
steps in Section 11.6, “Manually Downloading Module or Theme Files”. You can then continue here with
step 6 in the instructions for the administrative interface below.
185
CHAPTER 13. 安全和维护 13.6. UPDATING A MODULE
2. In the Manage administrative menu, navigate to Reports > Available updates > Update (admin/report-
s/updates/update).
3. Find and check the module in the list. Click Download these updates for the module.
4. Click Continue.
5. Click Run database updates. If you obtained the new module files manually, start with this step, and reach
the database updates page by typing the URL example.com/update.php in your browser.
6. Click Continue and apply all updates. The database update scripts will be executed.
Using Drush
1. Find the project name for the module you wish to update. It is the last segment of the module’s project
page URL. For example, if the project URL is https://www.drupal.org/project/admin_toolbar, the project
name is ”admin_toolbar”.
2. Run the following Drush command, giving the project name (for example, admin_toolbar) as a parameter
(if you have more than one module to update, add the additional module project names to the end of the
command, separated by spaces):
drush up admin_toolbar
186
CHAPTER 13. 安全和维护 13.7. UPDATING A THEME
Additional resources
Drupal.org community documentation page ”Updating modules”
Attributions
Adapted by Boris Doesborgh, and Sarah German at Advomatic, from ”Updating modules”, copyright 2000-
2017 by the individual contributors to the Drupal Community Documentation.
Prerequisite knowledge
• Section 13.3, “Concept: Security and Regular Updates”
• Section 13.1, “Concept: Cron”
Site prerequisites
• A contributed theme has been installed and there is an update available for it. See Section 11.5, “Down-
loading and Installing a Theme from Drupal.org”and Section 13.4, “Keeping Track of Updates”.
• If your site is live, you should test this process in a development environment before running it on your
production site. See Section 11.8, “Making a Development Site”.
• You have created a full site backup. See Section 12.3, “Concept: Data Backups”.
• If you want to use the user interface, the core Update Manager module must be installed. See Section 4.3,
“Installing a Module”for instructions on installing core modules.
• If you want to use Drush, Drush must be installed. See Section 3.2, “Concept: Additional Tools”.
Steps
You can use the administrative interface or Drush to update a contributed theme. If you are updating a custom
theme rather than a contributed theme, if you see a message saying Installing modules and themes requires
FTP access to your server, or if the steps below do not work to obtain the new theme files, follow the steps
in Section 11.6, “Manually Downloading Module or Theme Files”, and then continue with step 6 in the
instructions for administrative interface below.
2. In the Manage administrative menu, navigate to Reports > Available updates > Update (admin/report-
s/updates/update).
3. Find and check the theme in the list. Click Download these updates for the theme.
187
CHAPTER 13. 安全和维护 13.7. UPDATING A THEME
4. Click Continue.
5. Click Run database updates. If you obtained the new theme files manually, start with this step, and reach
the database updates page by typing the URL example.com/update.php in your browser.
6. Click Continue to run the updates. The database update scripts will be executed.
7. Click Administration pages to return to the administration section of your site.
8. Take your site out of maintenance mode. See Section 11.2, “Enabling and Disabling Maintenance Mode”
.
9. Clear the Drupal cache (refer to Section 12.2, “Clearing the Cache”).
Using Drush
1. Find the project name for the theme you wish to update, which is the last segment of the theme’s project
page URL. For example, if the project URL is https://www.drupal.org/project/mayo, the project name is
”mayo”.
2. Run the following Drush command, giving the project name (for example, mayo) as a parameter:
drush up mayo
Attributions
Written by Boris Doesborg.
188
Chapter 14
结语
Chat online The Drupal project uses IRC for on-line chatting. There are regional, topical, and general-
purpose chat groups available. Find out more on the ”IRC” page on Drupal.org.
Report a problem See below.
Contribute You can contribute your time and expertise to the community in many ways, such as:
• Developing modules or themes. See the ”Contribute to Development” page on Drupal.org, or im-
proving them (using the issue queues for existing projects).
• Translating the user interface. See localize.drupal.org.
• Writing documentation. See ”Contribute to Documentation” on Drupal.org.
• Answer Support questions. See Section 14.2, “Getting Support”.
189
CHAPTER 14. 结语 14.2. GETTING SUPPORT
Related topics
Section 14.2, “Getting Support”
Additional resources
• ”Code of Conduct” on Drupal.org
Attributions
Written by Jennifer Hodgdon, and Joe Shindelar at Drupalize.Me.
190
CHAPTER 14. 结语 14.3. LEARNING MORE
Second, some (but not all) contributed module, distribution, and theme projects encourage you to post
support requests in issues. Generally, projects that have a very large number of users do not allow support
requests in their issues (Drupal Core is in that category), while projects with a smaller number of users welcome
the occasional support question. Be respectful of developer time and read the documentation for the project
before posting a question in an issue. On the other hand, all projects encourage you to use issues to report
problems and bugs; see Section 14.1, “Connecting with the Community”to learn more about that.
In addition to those resources, the following sites provide free forums where volunteers answer support
questions about Drupal:
• The Drupal.org Forums
• ”Drupal Answers” on StackExchange
If you prefer to pay for support (presumably in exchange for more extensive service or better availability),
you can find service providers in the ”Drupal Marketplace” on Drupal.org.
Related topics
• Section 14.3, “Learning More”
Additional resources
• ”Support” page on Drupal.org
• ”Drupal Marketplace” on Drupal.org
• The Drupal.org Forums
• ”Drupal Answers” on StackExchange
Attributions
Written by Jennifer Hodgdon.
”Drupal Planet” page on Drupal.org An aggregation of blog posts about Drupal from around the web,
posted by blogging members of the Drupal community who have applied for inclusion. Topics range from
programming to site building to Drupal news.
Groups, events, and meetups See Section 14.1,“Connecting with the Community” for more about topical,
regional, and language groups, as well as local, regional, and international events.
191
CHAPTER 14. 结语 14.3. LEARNING MORE
”Training Marketplace” page on Drupal.org The Marketplace lists paid training providers. For free
training, check whether events include training sessions; there are also free or very low-cost training
events listed on the ”Global Training Days” page on Drupal.org.
Support sites See Section 14.2, “Getting Support”to locate support forums; searching them can be useful
for learning about specific topics.
Attributions
Written by Jennifer Hodgdon, and Joe Shindelar at Drupalize.Me.
192
Chapter 15
词汇表
Ajax
A web technology used to exchange data with a server to dynamically update parts of a web page (for
example, forms) without needing entire page reloads.
Alias
A user-friendly name to replace the internal path that the system assigns to a URL on the site. For exam-
ple, you might assign an alias of /about to the About page on your site, to replace the internal path /node/5.
This would give the page a URL of http://example.com/about instead of http://example.com/node/5. See
Section 5.1, “Concept: Paths, Aliases, and URLs”for more information.
Anonymous
A person (user) interacting with the site who is not logged in. See Section 7.1, “概念:用户,角色和权
限”for more information.
Block
A chunk of content (text, images, links, etc.) that can be displayed on a page of a site. Blocks are
displayed in regions. See Section 8.1, “Concept: Blocks”for more information.
Breakpoint
Breakpoints are used to separate the height or width of browser screens, printers, and other media out-
put types into steps. A responsive site adjusts its presentation at these breakpoints. See Section 6.14,
“Concept: Responsive Image Styles”for more information.
Bundle
Synonym for Entity subtype.
Cache
The site’s internal cache stores the output of time-consuming calculations, such as computing output
for an HTML page request, and then retrieves them instead of recalculating the next time they are
needed. External caching systems can also be used on the web server to speed up a site’s response. See
Section 12.1, “Concept: Cache”for more information on the internal cache.
CMS
Acronym for Content Management System.
Configuration
Information about your site that is not content, and is meant to be more permanent than state information,
such as the name of your site, the content types and views you have defined, etc. See Section 1.5,“Concept:
Types of Data”for more information.
Content
Information meant to be displayed on your site, such as text, images, downloads, etc. See also Configura-
tion and State. See Section 1.5, “Concept: Types of Data”for more information.
193
CHAPTER 15. 词汇表
Content item
An item of content that is typically meant to be displayed as the main content of a page on your site.
This is an entity type. See Section 2.3, “Concept: Content Entities and Fields”for more information.
Content Management System (CMS)
A collection of tools designed to allow the creation, modification, organization, search, retrieval and
removal of information on a website. See Section 1.1, “概念:Drupal 作为一个内容管理系统”for more
information.
Content type
An entity subtype for the content item entity type. Each content type is used for some particular purpose
on the site, and each has its own fields. For example, a site for a farmers market might have a content
type for simple pages, and another for a vendor listing page. See Section 2.3,“Concept: Content Entities
and Fields”for more information.
Contextual link
A link to an administrative page for editing or configuring a feature of the site, shown in the context
where that feature is displayed. Example: a link to configure a menu that is shown when you hover your
mouse over the menu. See Section 4.1, “Concept: Administrative Overview”for more information.
Contributed
Modules, themes, and distributions that are not part of the Drupal core download, and that can be
downloaded separately from the Drupal.org website.
Cron
On some operating systems, cron is a command scheduler application that executes commands or scripts
periodically. Your site defines periodic tasks, also known as cron tasks, that need to be triggered either by
an operating system cron scheduler, or internally. See Section 13.1,“Concept: Cron”for more information.
Distribution
A single download that provides a shortcut for setting up a specific type of site, such as a website for
a club or for e-commerce. A distribution contains Drupal core, along with contributed modules and/or
themes; many distributions also pre-configure the site or even create sample content upon installation.
See Section 1.4, “Concept: Distributions”for more information.
Drupal core
The files, themes, profiles, and modules included with the standard project software download. See
Section 1.1, “概念:Drupal 作为一个内容管理系统”for more information.
Entity
An item of either content or configuration data, although in common usage, the term often refers to
content entities. Examples include content items, custom blocks, taxonomy terms, and definitions of
content types; the first three are content entities, and the last is a configuration entity. See also Entity
type, Entity subtype, and Field. See Section 2.3, “Concept: Content Entities and Fields”for more
information.
Entity subtype
Within a content entity type, a grouping of entities that share the same fields. For example, within
the content item entity type, a farmers market site might have subtypes (known as content types) for
static pages and vendor pages, each with its own group of fields. You may also see the term bundle used
(especially in programmer documentation) as a synonym of entity subtype. See Section 2.3, “Concept:
Content Entities and Fields”for more information.
Entity type
The overall type of an entity; in common usage, it is only applied to a content entity. Examples include
content types, taxonomy terms, and custom blocks. See Section 2.3, “Concept: Content Entities and
Fields”for more information.
194
CHAPTER 15. 词汇表
Field
Data of a certain type that is attached to a content entity. For instance, on a farmers market site’s
vendor content type, you might have fields for an image, the vendor description, and a taxonomy term.
See Section 2.3, “Concept: Content Entities and Fields”for more information.
Field bundle
Synonym for Entity subtype.
Field formatter
Configuration that defines how the data in a field is displayed. For example, a text field could be displayed
with a prefix and/or suffix, and it could have its HTML tags stripped out or limited. See also View mode
and Field widget. See Section 6.10, “Concept: View Modes and Formatters”for more information.
Field widget
Configuration that defines how someone can enter or edit data for a field on a data entry form. For
example, a text field could use a single-line or multi-line entry box, and there could be a setting for the
size of the box. See also Field formatter. See Section 6.8, “Concept: Forms and Widgets”for more
information.
Formatter
See Field formatter.
FOSS
Acronym for Free and Open Source Software, meaning software that is developed by a community of
people and released under a non-commercial license. See also GPL. See Section 1.6, “概念:Drupal 项
目”for more information.
GPL
Acronym for the GNU General Public License, a non-commercial software license. All software downloaded
from the Drupal.org website is licensed under the ”GNU General Public License, version 2”. See also FOSS.
See Section 1.7, “Concept: Drupal Licensing”for more information.
Image style
A set of processing steps that transform a base image into a new image; typical processing includes scaling
and cropping. See Section 6.12, “Concept: Image Styles”for more information.
LAMP
Acronym for Linux, Apache, MySQL, and PHP: the software on the web server that the scripts commonly
run on (although it can use other operating systems, web servers, and databases). See Section 3.1, “概
念:服务器要求”for more information.
Log
A list of recorded events on the site, such as usage data, performance data, errors, warnings, and opera-
tional information. See Section 12.4, “Concept: Log”for more information.
Menu
A set of links used for navigation on a site, which may be arranged in a hierarchy. See Section 5.6,
“Concept: Menu”for more information.
Module
Software (usually PHP, JavaScript, and/or CSS) that extends site features and adds functionality. The
Drupal project distinguishes between core and contributed modules. See Section 1.2, “概念:模块”for
more information.
Path
The unique, last part of the internal URL that the system assigns to a page on the site, which can be
a visitor-facing page or an administrative page. For example, the internal URL for the About page on
your site might be http://example.com/node/5, and in this case, the path is node/5. See also Alias. See
Section 5.1, “Concept: Paths, Aliases, and URLs”for more information.
195
CHAPTER 15. 词汇表
Permission
The ability to perform some action on the site, such as editing a particular type of content, or viewing
user profiles. See also Role. See Section 7.1, “概念:用户,角色和权限”for more information.
Reference field
A field that represents a relationship between an entity and one or more other entities, which may be the
same entity type or a different type. For example, on a farmers market site, a recipe content item might
have a reference field to the vendor (also a content item) that posted the recipe. Taxonomy term fields
are also reference fields. See Section 6.4, “Concept: Reference Fields”for more information.
Region
A defined area of a page where content can be placed, such as the header, footer, main content area,
left sidebar, etc. Regions are defined by themes, and the content displayed in each region is contained in
blocks. See Section 2.1, “Concept: Regions in a Theme”for more information.
Responsive
A site or theme is said to be responsive if it adjusts its presentation in response to the size of the browser
screen, printer, or other media output type. See also Breakpoint. See Section 6.14,“Concept: Responsive
Image Styles”for more information.
Revision
A record of the past or present state of a content entity, as it is edited over time. See Section 2.6,
“Concept: Editorial Workflow”for more information.
Role
A named set of permissions that can be applied to a user account. See Section 7.1, “概念:用户,角色
和权限”for more information.
Security update
An update that fixes a security-related bug, such as a hacking vulnerability. See Section 13.3, “Concept:
Security and Regular Updates”for more information.
State
Information of a temporary nature about the current state of your site, such as the time when cron was
last run, etc. See also Content and Configuration. See Section 1.5, “Concept: Types of Data”for more
information.
Taxonomy
The process of classifying content. See Section 6.5, “Concept: Taxonomy”for more information.
Taxonomy term
A term used to classify content, such as a tag or a category. See also Vocabulary. See Section 6.5,
“Concept: Taxonomy”for more information.
Text format
Configuration that defines the processing that happens to user-entered text before it is shown in the
browser. This might include stripping or limiting HTML tags, or turning URLs into links. See Sec-
tion 6.15, “Concept: Text Formats and Editors”for more information.
Theme
Software and asset files (images, CSS, PHP code, and/or templates) that determine the style and layout
of the site. The Drupal project distinguishes between core and contributed themes. See Section 1.3, “概
念:主题”for more information.
UI
Acronym for User Interface.
Update
A newer version of your site’s software, either Drupal core or a module or theme. See also Security
update. See Section 13.3, “Concept: Security and Regular Updates”for more information.
196
CHAPTER 15. 词汇表
User
A person interacting with the site, either logged-in or anonymous. See Section 7.1, “概念:用户,角色
和权限”for more information.
User interface
The text, styles, and images that are visible on a site, separated logically into the user interface for site
visitors and the administrative user interface.
User one (User 1)
The initial user account that is created when you install the site (whose ID number is 1). It automatically
has all permissions, even if it is not assigned an administrative role. See Section 7.2,“Concept: The User
1 Account”for more information.
View
A formatted listing of data; typically, the data comes from content entities. For example, on a farmers
market site, you might create a content item for each vendor. You could then make view that generates a
listing page that shows a thumbnail image and short description of each vendor, linking to the full-page
content item. Using the same data, you could also make a view that generates a new vendors block, which
would show information from the most recently added vendors. See Section 2.4, “Concept: Modular
Content”for more information.
View mode
A set of field formatter configuration for all of the fields of a content entity, some of which may be hidden.
Each entity subtype can have one or more view modes defined; for example, content types typically have
Full and Teaser view modes, where the Teaser view mode displays fewer or trimmed-down fields. See
Section 6.10, “Concept: View Modes and Formatters”for more information.
Vocabulary
A group of taxonomy terms to choose from when classifying content in a particular way, such as the list
of all of the vendor categories on a farmers market site. Technically, vocabularies are the entity subtype
for the taxonomy term entity type. See Section 6.5, “Concept: Taxonomy”for more information.
Widget
See Field widget.
Wizard
A web form that allows you to fill in a few values, and creates something with sensible defaults based on
the values you chose. For example, there are wizards for creating views of different types. See Section 9.3,
“Creating a Content List View”for more information.
WYSIWYG
Acronym for What You See is What You Get, meaning a method for editing content where what you see
on the editing screen closely resembles the final product. See Section 6.16, “Configuring Text Formats
and Editors”for more information.
197
Appendix A
Appendix
199
APPENDIX A. APPENDIX A.1. GUIDE-WIDE ATTRIBUTIONS
• Grant Dunham
• Jennifer Hodgdon
• Joe Shindelar at Drupalize.Me
• Jojy Alphonso at Red Crackle — who copy edited the vast majority of the User Guide
• Kamal Kant Pansari at Intelliswift
• Zach Carter
• A workshop organized by the ”Spokane Drupal User Group” on groups.drupal.org, with students from
the Web Development Certificate program at Spokane Community College
Images
Most of the images in the guide are screen captures from the Drupal software, generated by software written
by Jennifer Hodgdon.
The word Drupal, the Druplicon logo (which appears as part of several images throughout the guide), and
the Drupal wordmark logo (which is part of the cover image), are registered trademarks of Dries Buytaert).
The cover image is a CC BY-SA 2.0 licensed illustration by Amanda Luker at Advomatic.
The Anytown Farmers Market logo, which appears as part of several images throughout the guide, is a CC
BY-SA 2.0 licensed illustration by Justin Harrell at Drupalize.Me.
The honey bee image, which appears as part of several images throughout the guide, is a public domain
image by John Severns at the English Wikipedia project via Wikimedia Commons.
The farm image, which appears as part of several images throughout the guide, is a public domain image
by Xianmin Chang via Wikimedia Commons.
The salad image, which appears as part of several images throughout the guide, is a public domain image
by Yinan Chen via Wikimedia Commons.
The carrot image, which appears as part of several images throughout the guide, is public domain im-
age K11611-1 by Stephen Ausmus at the Agricultural Research Service of the United States Department of
Agriculture via Wikimedia Commons.
• Qiangjun Ran
200
Index
201
INDEX INDEX
202
INDEX INDEX
203
INDEX INDEX
204
INDEX INDEX
205
INDEX INDEX
Page overview, 7
adding to menu while editing, 51 placing a block in, 115
composite, 11 primary menu, 7
Page cache secondary menu, 7
overview, 173 sidebar, 7
Path Regional setting
definition, 195 configuring, 30
overview, 43 Report
People menu entry Recent log messages, 176
administrative menu, 27 Reports menu entry
Performance administrative menu, 27
improving, 34 Resource
log report, 176 documentation and training, 191
status report, 177 Responsive
Permission definition, 196
changing, 106 Responsive image style
changing role, 108 overview, 96
definition, 195 Revision
denying, 106 definition, 196
granting, 106 overview, 13
PHP version Role
status report, 177 administrator, 101
PHP 编程语言 anonymous user, 101
版本要求, 15 authenticated user, 101
Planning changing, 108
site layout, 8 changing permission, 106
PostgreSQL 数据库 creating, 101
版本要求, 15 definition, 196
Primary menu region
overview, 7 Scenario for this document (farmers market)
Profile overview, xi
installation, 20 Secondary menu region
Published flag overview, 7
overview, 13 Security
assigning permission, 106
Quick editor, 47 cross-site scripting, 96
Quick-start distribution managing user accounts, 36
overview, 4 overview, 181
status report, 177
Reference field text format, 96
adding, 80 user account settings, 36
content, 70 user one account, 100
definition, 196 Security announcement
overview, 70 subscribing to by email, 182
taxonomy term, 70 subscribing to on Twitter, 182
user, 70 Security bug
Region reporting, 181
breadcrumb, 7 Security team
content, 7 overview, 181
definition, 196 Security update
featured, 7 applying, 185, 187
footer, 7 definition, 196
header, 7 keeping track of, 182
help, 7 Server information
highlighted, 7 status report, 177
menu, 7
206
INDEX INDEX
207
INDEX INDEX
208
INDEX INDEX
用户
概述, 99
用户角色
概述, 99
磁盘空间
安装要求, 15
第三方主题
概述, 3
管理用户账号
概述, 99
自定义主题
概述, 3
自由及开放源代码软件 (FOSS)
概述, 5
视图
上下文过滤, 120
关联, 120
字段, 120
排序标准, 120
显示, 120
格式, 120
组成, 120
过滤条件, 120
视图上下文过滤
209