第二部分 Drupal的扩展

回首页

第二部分 Drupal的扩展


Extend Drupal with contributed modules

用社区贡献的模块扩展Drupal

Want to customize your site and gain additional functionality? Hundreds of contributed modules are available.


Installing contributed modules

安装模块

Search for modules

搜索模块

The big three:Views,RulesandPanels

三大重要模块,视图,规则和面板

Getting started with Views

视图

Getting started with Rules

规则

Getting started with Panels

面板


Installing contributed modules

安装模块

Installing modules (Drupal 7)

Last updated November 10, 2015. Created on August 27, 2010.

Edited byashish_nirmohi,latikas,David_Rothstein,krina.soni.Log in to edit this page.

You can add third-party contributedmodulesto extend or alter Drupal's behavior.

Table of contents:

In a nutshell

Choose the module file

Upload the module

Option 1: Upload the module through the Drupal interface

Option 2: Upload the module manually

Enable and configure

In a nutshell

1. Download the module and extract it in the foldersites/all/modules/contrib. It is recommended to place all third-party modules in a subfolder calledcontrib.

2. Go to the Module page atAdminister > Modules(http://example.com/admin/modules)and enable it.

3. Read the module's documentation (readme file or on-line here on drupal.org) for further configuration instructions.

Note: Thedrushcommandsdrush dl module_nameanddrush en module_nameoffer probably the fastest way installing modules.

Choose the module file

Choose the right release.When you have chosen a module to add to your site, you must choose which release to use. The version must be compatible with the version of Drupal you are using. Note that 'Development releases' are versions of the module that are in an active stage of development. They may be written for a previous/current/future version of Drupal, are considered unstable, and should be handled with care. 'Recommended releases' are stable and ready to use.


Upload the module

There are two basic ways to upload module files to a Drupal 7 site:

Through the Drupal user interface

Manually on the server

The first option will not work on many types of servers, but may be a more user-friendly choice on servers where it does work. The second option is always available.

Option 1: Upload the module through the Drupal interface

Navigate to the install page.Navigate toModules > List (tab), orhttp://example.com/admin/modules, and click the link 'Install new module.' (You must have theUpdate managermodule enabled to see this link. For those new to Drupal, go to "Modules", find "Update Manager," put a check mark in the box by "Update Manager" and then click "Save" at the bottom of the page. You should now have a link to install new modules.)

Follow the prompts.You will be prompted to provide either the URL to the download, or to upload the .tar.gz or .zip file from your local computer. Click 'Install', and the Update manager will copy the files into yoursites/all/modulesfolder. (SeeUpdate managerfor more information about what that core module can do.) The next screen gives you two links. Click 'Enable newly added modules' and skip down to the 'Enable and configure' section.


If your site asks for your FTP username and password, it is referring to the username and password to accessyoursite, not drupal.org

A note about FTP: If FTP is not enabled for your server, you may receive an error message. Drupal will not be able to diagnose the problem, only tell you that there is one. It's up to you to determine whether your server is properly configured for FTP.

Option 2: Upload the module manually

Extract the files.The downloaded module package will be in a compressed file format such as 'tar.gz'. On Windows, use a program like7-zipto extract the files. On modern Mac systems, double-click the .tar.gz file. On Linux or similar systems, use the command line:

tar-zxvf modulename-drupalversionnumber.tar.gz

You should see a list of files extracted into a folder.

Upload the folder.

Transfer your files with SFTP or FTP to the desired modules folder in your Drupal installation (or if you are using version control, add and commit them to your code repository). The modules folder at the top level of your Drupal installation is reserved for Drupal core modules (the ones that come with the original download of Drupal). Contributed modules belong insites/all/modules. If you are running amulti-site installationof Drupal, usesites/my.site.folder/modulesfor modules there that are specific to a particular site in your installation. Modules that will be shared between all sites should be placed insites/all/modules.

Please note: Especially for sites with a lot of additional modules, many people have begun to further divide the modules folder, to help stay organized. A typical way of doing this would be:

sites/all/modules/contribfor all contributed modules.

sites/all/modules/customfor all custom modules.

sites/all/modules/featuresif you have additional modules that were created usingFeatures.

Enable and configure

Read the directions.If the module has an installation file (usually INSTALL.txt and/or README.txt), read it for specific instructions. There are modules that require special treatment, and even modules that depend on other downloaded files to function properly. Sometimes the README file has no .txt extension. If you double-click it, your computer won't know what program to use. In that case, open a text editor first, and then open the file using the editor's 'file open' command.

Enable the module.Navigate toAdminister > Modulesorhttp://example.com/admin/modules. Check the 'Enabled' box next to the module and then click the 'Save Configuration' button at the bottom.Note: If you are updating an existing module, you'll need to click 'update script' at the top of the page or loadhttp://www.example.com/update.php, then click 'Continue' (after making a backup of both your database and 'sites' folder).

Set up permissions.Some modules will require that you change permissions to get them working. Permissions information may be in the instructions that came with the module. Navigate toAdminister > Modulesand click on the 'Permissions' button for the desired module.

You can also do this on the Permissions page (Administer > People > Permissions). Scroll down to see if the module appears in the list and, if it does, give the appropriate permissions to desired roles.


Adjust settings.Most modules will have some type of settings page. It will vary from module to module but if not described in the README.txt file, it can usually be located by navigating to (Administer > Modules) and clicking on the 'Configure' link for that module. Not all modules have settings pages.

Please note: You can only have one copy of a module with the same name in each Drupal site. The module's name is determined by the name of the.modulefile, not by the name of the directory.

Tip: If you run into problems, search the module's issue queue and theforums. If your problem hasn't already been addressed, post a question or issue and someone will try to help you out.

Tip: To keep up-to-date on any issues and fixes related to your newly installed module(s), you cancreate a user accounton Drupal.org (if you haven't done so already) and then subscribe to the feed of each module you are using.


For a collection of useful materials for module developers, seeModule Development with Drupal.

AttachmentSize

versions.png173.63 KB

install_new_module_via_drush.jpg248.68 KB


Getting started with Views

视图

Working with Views to display sets of content

Last updated November 25, 2015. Created on January 15, 2007.

Edited bykakinne,mikenzig,pachabhaiya,HongPong.Log in to edit this page.

Using theViewsmodule, you can fetch content from the database of your site and present it to the user as lists, posts, galleries, tables, maps, graphs, menu items, blocks, reports, forum posts etc. Different content types including nodes, users, and other bundles can be displayed.

Views UI, a submodule within Views, provides a graphical interface underneath which lies a powerful SQL query builder that can access virtually any information in your database and display it in any format.

Different displays can present the query results as pages with fixed URLs on your site (or URLs accepting arguments), blocks, feeds, or panel panes.

You can also use Views to present related content or implement contextual filters. An example of presenting related content is when you want to display a list of users along with links to the content they have created. To do this, you need to create a relationship linking two nodes. You can create a relationship by navigating to Advanced settings in your Displays page and clicking on "Add Relationship." Once the proper relationship is set up, you can add the fields from the linked node that you would like to display. An example of where you would want to use a contextual filter is if you want to display customized content to a user according to their user ID. To do this, navigate to the advanced settings on the display page and click on add contextual filter. In this case, you would want to add a filter for content: Nid.

Views has been added to Drupal 8 core.

Understanding Views versus custom code

Working with Views in Drupal 7 and earlier

Working with Views in Drupal 8

Views-related contributed modules

Views video tutorials

Views tips and tricks

Views issue queue


Getting started with Rules

规则

Rules: Actions Automations

Last updated September 8, 2014. Created on August 22, 2008.

Edited bysamwilson,iantresman,3lackRos3,eft.Log in to edit this page.

This is Rules

Rulesis an engine for automating actions in Drupal. Rules can react to events occurring on your site, such as a user logging in or a node being submitted, and it can perform customized follow-up actions such as redirecting to a certain page or setting field values.

Rules is also a framework used by other modules, allowing them to expose user-reconfigurable components with sets of actions and conditions that are managed in easy to import/export configuration files. Rules leverages Entity API to read and act on data and work seamlessly with all types of variables and entities.

In addition to this handbook,The Tiny Book of Rulesoffers a condensed and portable handbook, andChapter 12ofDrupal 7 – The Essentialsis part of a larger resource on Drupal.

Historical note: the Rules module is the successor of theWorkflow-ng modulefor Drupal 5; it is a replacement for theTrigger module, which is in Drupal 7 Core and has been removed from Drupal 8.

2. Site Builder Documentation

Introduction to Rules

3. Developer Documentation

4. Contributed Features and Examples

5. Project Resources

6. Drupal 6 (Rules 1.x)


Getting started with Panels

面板

Creating complex layouts with Panels

Last updated November 4, 2015. Created on November 8, 2009.

Edited bykkosinsk,shamio,HongPong,LeeHunter.Log in to edit this page.

ThePanels moduleallows a site administrator to create customized layouts for multiple uses. At its core it is a drag and drop content manager that lets you visually design a layout and place content within that layout.

Integration with other systems allows you to create nodes, sophisticated section indexes and landing pages that use panels, and even override system pages such as taxonomy and the node page so that you can customize the layout of your site with very fine grained permissions & behavior.

Panels can also dynamically control arguments going into blocks, passing variables like user names into blocks. Panels streamlines the creation of complex Drupal pages by letting site developers combine views, blocks, and other system elements (like the site slogan or logged-in user pictures).

Panels 3 is the most recent version ofPanels, and is a significant advance over Panels 2, although its user interface is similar. A non-final release of Panels 3 is available for Drupal 7.

Panels 2 for Drupal 6 is deprecated. SeeUpgrading from Panels 2 to Panels 3if you are currently using Panels 2 on Drupal 6.

Many useful Panels videoshave been created by Drupal community members.

Panels 2 Documentation

Panels 3 Documentation

Panels Everywhere Documentation

Obtaining support for Panels issues

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,117评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,328评论 1 293
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,839评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,007评论 0 206
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,384评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,629评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,880评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,593评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,313评论 1 243
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,575评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,066评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,392评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,052评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,082评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,844评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,662评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,575评论 2 270

推荐阅读更多精彩内容