Depending on who you talk to, you’ll hear Drupal called a Content Management System (CMS) or a Content Management Framework (CMF, a platform that you can use to build a custom CMS)--and both are accurate. It can be called a basic CMS because after installing only the base Drupal software, you can create a website with forums, static pages, and/or a blog, and manage the content online. On the other hand, it can be called a flexible CMF because most people choose to add additional modules to Drupal in order to build more complicated websites with more features, and Drupal also allows you to create fully custom modules.
Drupal is free and open-source software (FOSS), governed by the GNU General Public License (GPL) version 2 (or, at your option, any later version). If you have never read the GPL and plan to use Drupal, you would be well advised to do so (even more so if you plan to do any Drupal programming, for yourself or others). The GPL governs not only what you can do with Drupal software itself, but also what you can do with any add-ons you download from drupal.org, code you find on drupal.org documentation pages, and any derivative work (work that contains GPL-licensed work, verbatim or with modifications) that you or others create. It’s also written in plain English and is quite a good read (for programmer-types anyway); you can find it in the LICENSE.txt file distributed with Drupal core, or at http://gnu.org.
And finally, Drupal is also a project and a community. Unlike some FOSS software that is developed primarily by one company that later releases the source code to the public, Drupal is continually evolving due to the efforts of a world wide community of individuals and companies who donate their time and money to create and test Drupal software, write the documentation, translate it into other languages, answer support questions, keep the drupal.org web servers running, and organize get-togethers on a local and world wide scale.
- A URL request dispatch system
- A user account management system with flexible permissions and roles
- Online content editing
- A theme (template) system, which lets you override how everything from a button to an entire page is displayed
- A block system that allows you to place chunks of content in various regions of a site’s pages (this system will be quite different in Drupal 8, and more flexible).
- A navigation menu builder
- A flexible taxonomy system that supports categories, tags, and user-defined taxonomy vocabularies
- Optional modules supporting commenting, content fields, RSS aggregation, search, and site features such as forums and polls (depending on the Drupal version, some of these may require downloading add-on modules instead of being part of Drupal core)
- The ability to set up a site in different languages and translate content (depending on the Drupal version, some add-on modules may be required to make a multi-lingual or non-English site)
- Logging of system events and errors
- An API for Drupal programmers
Drupal is modular software, meaning that you can turn site features and functionality on and off by enabling and disabling modules. Drupal core comes with a few required modules and several optional modules; you can download thousands of additional contributed modules from http://drupal.org/project/modules. Most modules have configuration options that you can modify from the Drupal administration interface, by logging in to the Drupal-based site using an account that has been given appropriate permissions. The permission system is flexible: you can define named roles, which are granted specific permissions (the permissions are defined by modules), and you can assign one or more roles to each user account.
Drupal uses a theme system to separate the content from the specific HTML markup and styling. This means that if you want to redesign the site’s layout or styling, you can do so by downloading a new theme from http://drupal.org/project/themes, purchasing a commercially available theme, or creating one yourself—once installed and enabled, it takes effect immediately to change the look of your site without the necessity of editing your content pages. The theme system allows you to use the default display for whatever you are happy with and override the parts you want to change; the overrides can be at anything from the lowest level (for example, the presentation of buttons) to the full page.
You can also download Drupal in a distribution, which consists of Drupal core and a collection of contributed modules and themes that work together to provide a more functional site for a specific purpose. Distributions are available at http://drupal.org/project/distributions for e-commerce, government, non-profits, and many other purposes.
And finally, you can download translations for Drupal and its contributed modules, themes, and distributions from http://localize.drupal.org. As of Drupal version 7, this is unfortunately more complicated than installing a module or theme, even more so if you want to set up a multilingual site. It should be improved in Drupal 8.
Here are the main ways to find Drupal add-ons (modules, themes, or distributions):
- To find a specific add-on that you know the name of, visit http://drupal.org and type the name into the search box.
- If it’s not in the first few results, try restricting the search to modules or themes, using the filters in the right sidebar (there is no way to restrict to distributions as of this writing).
- Alternatively, start by navigating to http://drupal.org/project/modules, http://drupal.org/project/themes, or http://drupal.org/project/distributions, and searching from there.
- You can try guessing the URL, which is always drupal.org/project/, followed by the machine name of the project. The machine name is composed of lowercase letters, numbers, and underscores, but as the machine names are chosen by developers, some are hard to guess and they may take a couple of tries. For example, the Views module is at http://drupal.org/project/views; the Pixture Reloaded theme is at http://drupal.org/project/pixture_reloaded; the XML Sitemap module is at http://drupal.org/project/xmlsitemap.
- If you don’t know the name, you can search from http://drupal.org/project/modules, http://drupal.org/project/themes, or http://drupal.org/project/distributions by keyword, Drupal version compatibility, or category (for modules only).
When Drupal is installed properly and the web server receives an HTTP request that corresponds to the Drupal site, the main Drupal index.php file is loaded and executed by the server to handle the request. It is important for Drupal programmers to understand how Drupal handles such requests; here is an overview (see also Figure 1-1):
- Drupal determines which settings.php file to use for the HTTP request (you can set up Drupal to serve multiple sites, each with its own settings.php file), and this file is loaded and executed.
- If a URL request is coming from an anonymous user (a site visitor who is not logged in), the page cache is checked to see if output has previously been cached for the same requested URL. If so, the cached output is returned to the web server, and Drupal is done. Drupal page caching does not apply to authenticated (logged-in) users.
- The database connection, configuration/variable system, and PHP session variables are initialized.
- The language system is initialized, and various files are loaded and executed (core include files and enabled modules' .module files).
- Drupal determines whether the site is offline (also known as being in maintenance mode) or online.
- If the site is offline, Drupal retrieves the offline message stored by an administrator as the page content. Other functions are called to generate some sections of the page content.
- If the site is online, or if an authorized user is accessing a page while the site is offline, Drupal determines which functions need to be called to generate the content for the request, and calls these functions. They ideally return raw, prerendered content, but they could also return rendered or partially rendered content.
- Drupal determines what delivery method to use for the page, and calls the appropriate delivery function.
- For HTML page requests, the default page delivery function prints HTTP headers, uses the theme to render the raw content into HTML, prints the HTML output (which effectively sends it to the web server), saves user session information to the database, and exits. The AJAX request delivery function is similar, but it renders into JSON output instead of using the theme system to render to HTML. Modules can also define custom page delivery methods.
In Drupal 8, some of this high-level overview will still apply, although the details behind the steps will be changing significantly. In particular, fewer files will get loaded, and philosophically, Drupal will be oriented towards responding to generic HTTP requests containing session variables and other context information, rather than returning HTML pages given a URL.
Drupal has a cache system, which allows modules to precalculate data or
output and store it in the database so that the next time it is needed it
doesn’t have to be calculated again. This can save a lot of time on page loads,
at the expense of some added complexity: any module that uses caching needs to
take care to clear its cached data whenever the data is invalidated due to
changes in dependent data. The Drupal 7 cache system has a fairly simple API,
consisting of functions
cache_get() (with a few variations),
as well as
cache_clear_all() to clear all database caches, including
module-specific caches. Modules can register to have their caches cleared by
implementing a hook (hooks are module entry points to altering Drupal) called
Both Drupal core and add-on modules cache information using this system. Here are a few examples:
- Page output for anonymous users (page caching can be turned off from the Performance configuration page)
- Block output (block caching can also be turned off from the Performance page)
- Menu routing (URL) information, block registration information, and other information collected from modules
- Theme information, including the list of theme regions and theme-related information from modules and themes
- Form arrays
Programmers and site builders new to Drupal quickly learn that the first thing to try, if they are having trouble with a site or if programming changes they have recently made are not being recognized, is to clear the cache. You can clear the cache by visiting the Performance configuration page and clicking the cache clear button, or by using Drush.
Related topics, examples, and references:
- See Principle: Drupal Is Alterable to learn more about hooks in general, including theme hooks
- See http://api.drupal.org to find full documentation of the cache functions mentioned here
- For more information on Drush, see Drupal Development Tools
- The Cache example from the Examples for Developers project (http://drupal.org/project/examples) illustrates how to use the Cache API
- Cache in menu routing: Registering for a URL and the Page example from Examples for Developers
- Cache in block registration: Registering a Block and the Block example from Examples for Developers
- Views cache: Creating Views Module Add-Ons
- Theme cache: Defining Theme Regions for Block Placement and Making Your Output Themeable
- Forms: Generating Forms with the Form API and the Form example from Examples for Developers
The cache API functions are different in Drupal 8 because it uses classes to manage caching.