Drupal Modules 101: Introduction, installation, and removal
Or: The What, When, Where, Why, and especially How
Versions of this talk has been presented at:
- BAD Camp 2013
- Stanford Drupal Camp 2013
- Drupal Camp @ Stanford 2012
- 12 Nov 2011 Stanford Tech Briefing
- BADCamp 2011 (video available)
What are modules?
Drupal is designed to be modular. Instead of always having every possible tool or feature in every site's code, you can just have those you're actually going to use.
Drupal core —what you get when you install Drupal— is like a very basic box of Lego™: a platform and some basic bricks (modules) to get you started. You can do a lot with just those basics, but usually you'll want more.
That's where contributed modules come in. Contributed modules are packages of code that extend or enhance Drupal core to add additional (or alternate) functionality and features. These modules have been "contributed" back to the Drupal community by their authors.
When should you use contributed modules?
"The Drupal Way" can be summed up as both "Don't re-invent the wheel" and "Share and share alike". Although you may be perfectly capable of writing your own custom module to add some feature/functionality to your Drupal site, you should always first check to see if there is an existing module that does (or nearly does) what you want.
Using contributed modules not only saves initial coding time, it also makes it significantly easier for you and, especially, others to maintain the site in the future. Contributed modules also benefit from multiple eyes and multiple users to find problems and improve code.
Where can you find contributed modules?
Contributed modules live on Drupal.org, specifically, at http://drupal.org/project/modules. You can search the module list and filter it by category, Drupal version, and status. You can also sort based on most installed, title, author, last release date, etc.
Why should you choose one module over another?
Choosing which contributed modules to use is an art. There isn't an easy list of objective criteria to be checked off. There are, however, various factors that should be weighed when evaluating modules:
- Suitability for your purpose
- Release status
- Recommendations by experienced Drupallers
- Usage statistics (http://drupal.org/project/usage/[module_name])
- Issue queue (not just outstanding issues, but response time, etc.)
- Development activity
- Author & maintainers
For more about how to choose modules, see Karen Stevenson's excellent session at DrupalCon Munich 2012 There Might (Not) Be a Module for That.
How do you install modules (step-by-step)?
For both Drupal 6.x and Drupal 7.x, there are just four major steps to adding a contributed module to a Drupal site:
- Upload the module code
- Enable the module
- Set permissions for the module
- Configure the module
The four steps in detail
-
Upload the module code
- Upload (install) the module's file directory into the
sites/all/modules/
directory - Preferably, upload as a compressed archive (.zip, .tar.gz) and expand the archive on the server (rather than expanding on your desktop and uploading as a folder with individual files). This is both quicker and avoids potential problems with file permissions or invisible files not making the transition.
- Upload (install) the module's file directory into the
-
Enable the module
- Go to the Modules administration page:
- Drupal 6: Administer->Site building->Modules (
/admin/build/modules
). - Drupal 7: Modules (
/admin/modules
).
- Drupal 6: Administer->Site building->Modules (
- Enable (check) the relevant module and sub-module(s), if any.
- Scroll down to the very bottom of the page and click the Save configuration button.
- Go to the Modules administration page:
- Set permissions for the module
- Go to:
- Drupal 6: Administer->Site building->Modules, then click Administration by Module page in the third paragraph down (
/admin/by-module
). - Drupal 7: Modules (
/admin/modules
).
- Drupal 6: Administer->Site building->Modules, then click Administration by Module page in the third paragraph down (
- Find the relevant module.
- If present for that module:
- Drupal 6: Click Configure permissions
- Drupal 7: Click Permissions
- Set permissions as appropriate.
- Scroll down to the bottom of the page and click the Save permissions button.
- Go to:
-
Configure the module
- Go to:
- Drupal 6: Administer->Site building->Modules, then click Administration by Module page in the third paragraph down (
/admin/by-module
). - Drupal 7: Modules (
/admin/modules
)
- Drupal 6: Administer->Site building->Modules, then click Administration by Module page in the third paragraph down (
- Find the relevant module.
- If present for that module:
- Drupal 6: Click [Module name] settings and, in turn, any other link(s) (besides Configure permissions or Get help)
- Drupal 7: Click Configure
- Configure as appropriate.
- Don't forget to Save any configuration changes!
- Go to:
How do you uninstall modules (step-by-step)?
For both Drupal 6.x and Drupal 7.x, there are just three major steps to removing a contributed module from a Drupal site:
- Disable the module
- Uninstall the module
- Delete the module code
The three steps in detail
-
Disable the module
- Go to the Modules administration page:
- Drupal 6: Administer->Site building->Modules (
/admin/build/modules
). - Drupal 7: Modules (
/admin/modules
).
- Drupal 6: Administer->Site building->Modules (
- Disable (uncheck) the relevant module and sub-module(s), if any.
- Scroll down to the very bottom of the page and click the Save configuration button.
- Go to the Modules administration page:
-
Uninstall the module
- Return to the Modules administration page:
- Drupal 6: Administer->Site building->Modules (
/admin/build/modules
). - Drupal 7: Modules (
/admin/modules
).
- Drupal 6: Administer->Site building->Modules (
- Click the Uninstall tab.
- Select (check) the relevant module.
- Click the Uninstall button.
- When asked "Would you like to continue with uninstalling the above?", confirm by clicking the Uninstall button.
- Return to the Modules administration page:
- Delete the module code
- Remove the module's file directory from the
sites/all/modules/
directory
- Remove the module's file directory from the
Comments
question - author/maintainers??
Question about "Why should you choose one module over another?" ... Author & maintainers:
Which factors about "Author & maintainers" are you checking when you evaluating some modules?
Author & maintainers
Whoops, meant to reply to this much sooner! Anyway…
As you get more involved with Drupal, you often become familiar with various contributors and their work. So when a module is contributed by or maintained by someone who you know does good work (both from coding and maintenance standpoint), that can be considered a Good Sign. It is just one factor among many, and if a module you're interested in is written/maintained by a contributor you know nothing about, that's just a factor you don't get to make use of, rather than something to count against using the module. (I do not recommend spending time trying to research the reputations of contributors you don't know —just evaluate based on the module, it's issue queue, module recommendations by experienced Drupallers, etc. in such cases.)