回首页
第二部分 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:
Option 1: Upload the module through the Drupal interface
Option 2: Upload the module manually
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
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.
4. Contributed Features and Examples
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.
网友评论