If you run a business or organization of any kind, proffering a Web site is no longer a luxury. Like a logo, an effective Web site is now a crucial component of identity, branding, and communication. A physical locale may be a thing of the past — you can't walk into Amazon, for instance — but fostering, bolstering, and rewarding customer loyalty is no less important. A Web site attracts customers, and its features engage and retain those same consumers.
Given the significance of a Web presence, it's little wonder that many organizations invest heavily in technology and staff to create, operate, and maintain compelling Web sites. For example, the New York Times spends richly to develop novel software to provide online access to its daily content, as well as its vast archive of historic content. Similarly, Mini USA, with intentionally few auto showrooms in the United States, allows you to build a car from scratch via the Web.
Although few publications match the scale of the Times, and few retailers sell $30,000 items, every periodical and store has much the same goals as NYTimes.com and MiniUSA.com, respectively. Hence, a wide range of Web-site authoring solutions is available to meet every budget. Off-the-shelf software with prescribed features is at one extreme of the spectrum; custom development is at the opposite pole; and all combinations lay in between.
Interestingly, one piece of open source software spans the entire spectrum. Drupal can be used effectively right off the shelf. It can also be modified extensively (it's open source, after all) and amended with custom code. And Drupal can suit any variation in between, depending on the requirements, technical savvy, and financial resources of the organization.
Indeed, over the past three years, the Drupal content-management system (CMS) has exploded in popularity. Drupal is free to deploy. The software is easy to install on any platform that supports PHP, and because it's easy to extend, and its catalog of available adds-ons is immense, Drupal can grow to accommodate the needs of a budding Web site.
Drupal V5 was released in early 2007, and Drupal V6 — the latest significant revision — debuted a year later. Drupal V5 is actively maintained to address emergent security issues, but the bulk of new development, including fundamental enhancements, extensions, and themes, is focused on Drupal V6. There is also a nascent effort to create Drupal V7, but it is far too soon to predict its availability or suitability for production Web sites.
This article looks at the improvements and fresh features found in Drupal V6. This first installment introduces Drupal, explains key concepts used throughout the software, lists some of the new features in Drupal V6, and demonstrates how to install the package in a home directory on Mac OS X (installation is similar on Windows®, Linux®, and UNIX®). Subsequent installments in this "Exploring Drupal" series will detail how to extend a basic installation with modules and themes and how to administer a growing Drupal site, including tips and tricks, such as search engine optimization and internationalization.
A quick tour of Drupal internals
Drupal is a CMS for the Web. Its coin is the story. Drupal collects and manages stories and supplemental information, such as accompanying images, comments, ratings, and links, and presents them in various formats, such as a blog, an archive, or an RSS feed.
Much like other Web applications, Drupal is based on the Apache, MySQL, PHP (AMP) stack. Apache is the Web server and transits requests and replies between client systems and itself. MySQL is the story repository; it is a relational database able to yield specific data quickly. And PHP is the computer language and interpreter used to code and execute Drupal. Combined, AMP and Drupal process each request for a story and respond with the correct data in a formatted page or feed.
The Drupal core provides essential features, such as user management, session management, and templating. It also provides an API so an arbitrary number of subsystems can add features above and beyond those offered by the core. Each subsystem is called a module.
Drupal separates content from presentation. In other words, a story typically does not dictate how it appears on a page. Instead, a theme, or style, affects its appearance. Theme management is part of the core; each theme is an individual add-on.
Of course, the core also manages stories, or what Drupal calls nodes. A node records a minimum of information, including an ID, a title, status, a type, and an author, among a handful of other values. More extensive or specialized information is added to a node via modules.
The node is the hallmark of Drupal. Because it is minimal and enforces so few semantics, a module can derive a new node type or extend a node. For example, a video module can create a new node type based on a vanilla node. A ratings module can extend any node to include grades. Separately and simultaneously, a commenting module can associate free from commentary, discussion, and debate with any node.
Figure 1 captures Drupal's model of nodes. The basic node is shown at top and includes a modicum of core fields. Two new types of nodes are derived from the base node: one for video and another for a podcast. Meanwhile, one module extends all nodes to include rating data, and another module extends all nodes to include commentary.
Figure 1. The conceptual model of a Drupal node
New features in Drupal V6
The list of improvements found in Drupal V6 is extensive. Here are some of the most important changes:
- Snappy installation — Historically, Drupal has been easy to install, as the application bootstrapped itself. However, some vital parameters had to be modified separately. The Drupal V6 installer streamlines the process. Virtually every option is configured during setup.
- Automatic updates — Given the Drupal core and the many modules a site can install and operate, the task of keeping a Drupal V5 deployment up to date grew onerous, requiring the site administrator to track, download, and install umpteen revisions. Drupal V6 automates maintenance. Alerts provide notification that new code is available, and updates are installed with a click of the mouse.
- Action-generating events — Drupal V6 can tie an action to an event via a trigger. For example, a trigger can send you e-mail whenever new content is posted or can demote a front-page story if the story is edited. There are five trigger variants and 16 predefined actions, but more can be added via code.
- Abstracted database — Drupal supports MySQL and PostgreSQL, two of the most popular open source databases. The databases are similar, but differ enough that the variations between the two complicate module development. Typically, one batch of SQL code is written for MySQL, and another raft of SQL code is written for PostgreSQL. To allay rework, Drupal V6 introduces a programmatic interface that abstracts common SQL operations, providing a single technique for altering the schema independent of the database engine.
- Language support — Support for internationalization has been refined and expanded. Translation is now a part of the core; each domain, URL, and user can express a language preference; and core themes support left-to-right and right-to-left writing systems.
And there's a lot more. Drupal now supports user login via industry-standard OpenID. You can emit log messages to the system's syslog daemon. You can customize date formats. And you can reject PHP code in content, addressing a long-standing vulnerability.
Let's install Drupal V6 on Mac OS X V10.5 Leopard. Mac OS X is ideal because it includes the entire AMP stack, and you can run a complete Drupal Web site from your personal Sites directory. (Linux, UNIX, and Windows users can consult the INSTALL.txt file included with Drupal for instructions for those platforms. Installation on the latter three platforms is straightforward.)
- Download the source code to the latest version of Drupal V6 from Drupal.org. After a moment, you should have a file named something like drupal-6.12.tar. (At the time of writing, the latest version of Drupal V6 was V6.12).
- Copy the file to the Sites directory located in your Home directory, then double-click the file to expand it in place.
- Open the newly created directory, drupal-6.12, and navigate to the subdirectory sites/default. Using the Finder, duplicate the file default.settings.php and rename the copy settings.php.
- Select settings.php, then press Cmd+I. Expand the Sharing & Permissions
section at the bottom, click the lock icon to authenticate, and
change permissions to allow your group and others read-and-write
access to the file. Your settings should resemble Figure 2.
Figure 2. Allow everyone read-and-write permission
- Change the permissions of the sites/default directory to allow others to
write to the directory:
- Navigate to the Drupal site directory.
- Click Default, press Cmd+I, then authenticate.
- Change permissions to allow everyone read-and-write access.
- Create the database for your new Web site.
You commonly perform this step via the command line, although
phpMyAdmin and Navicat offer a windowing interface to database
management. The command
mysqladmin create drupaldemocreates a new database named drupaldemo. If you are comfortable with Terminal and the command line, you can ignore the Finder and the previous steps and perform all the necessary work directly from the prompt:
$ cp drupal-6.12.tar ~/Sites $ cd ~/Sites $ tar xvf drupal-6.12.tar $ rm drupal-6.12.tar $ cd drupal-6.12 $ cp ./sites/default/default.settings.php ./sites/default/settings.php $ chmod a+w ./sites/default/settings.php $ chmod o+w ./sites/default $ mysqladmin create drupaldemo
- Run the Drupal V6 installer:
- Point your browser to http://localhost/~username/drupal-6.12,
where username is your short login name. You should see the Drupal opening
screen, which resembles Figure 3.
Figure 3. The opening Drupal screen
- Click Install Drupal in English. The next screen prompts for the Drupal database name you created earlier, as well as a login and password to access the database.
drupaldemofor the database name, then type the name and password of a user who has access to the database.
- Click Submit. At this point, Drupal no longer needs special access to
site/default/settings.php or site/default. For the former
file, use Finder to revoke write privileges for everyone
other than yourself. For the latter file, use Finder to revoke
write privileges to other and everyone. From the Terminal,
use these commands:
$ chmod 644 sites/default/settings.php $ chmod 755 sites/default
- Complete the form to configure the site:
- Choose a friendly name for the site, such as Drupal Demo.
- Provide an e-mail address for the Web site administrator.
- Specify a name for the administrator.
- Set and confirm the password, then click
Save and Continue. Figure 4 shows the result.
Figure 4. The Drupal site administration page
- Point your browser to http://localhost/~username/drupal-6.12, where username is your short login name. You should see the Drupal opening screen, which resembles Figure 3.
A CMS is of little use without content, so let's create a story. Expand Create content at the left, then click Story. The form provides a field for a title, a body, and a variety of options.
Enter a title and an introduction, as well as some prose for the body. To delineate the introduction from the rest of the story, set your cursor after the introduction, then click Split Summary at Cursor. Now everything above the bar is a summary, or preview, of the article. Everything below the bar is the story. You can elect to show or hide the summary when the story is displayed in full. Figure 5 captures the state of a story in process.
Figure 5. Editing a new story
Click the arrows to expose other options. The Revision information option keeps prior editions of the same story. The Input format can restrict content to a tiny subset of HTML. And you can use the Menu settings to craft a menu hierarchy from content.
When finished, click Save and admire your work. Figure 6 shows the new front page of the site.
Figure 6. Front page of the site after adding the first story
Figure 7 shows the detail page.
Figure 7. Detailed story page
If you work with Drupal even for a short time, you'll quickly be enamored. The software is easy to launch from scratch, and its core features and portfolio of contributed modules make it flexible, extensible, and adaptable. If you want a Web presence fast, Drupal is a worthwhile option sure to pay dividends on your investment.
- Check out Part 2 and Part 3 for more information about Drupal.
- Visit Drupal.org to find documentation, add-on modules, and other resources, as well as connect with others in the Drupal community.
- Visit CMS on Wikipedia Wikipedia to learn more about content-management systems.
- Check out the Theme Garden showcase of available Drupal themes. Similarly, Drupal Modules is a searchable database of available Drupal modules.
- Check out CMSWatch reviews to determine whether Drupal or another CMS meets your requirements.
- To listen to interesting interviews and discussions for software developers, check out developerWorks podcasts.
- Stay current with developerWorks' Technical events and webcasts.
- Follow developerWorks on Twitter.
- Check out upcoming conferences, trade shows, webcasts, and other Events around the world that are of interest to IBM open source developers.
- Visit the developerWorks Open source zone for extensive how-to information, tools, and project updates to help you develop with open source technologies and use them with IBM's products.
- Watch and learn about IBM and open source technologies and product functions with the no-cost developerWorks On demand demos.
Get products and technologies
- Innovate your next open source development project with IBM trial software, available for download or on DVD.
- Download IBM product evaluation versions or explore the online trials in the IBM SOA Sandbox and get your hands on application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.
- Participate in developerWorks blogs and get involved in the developerWorks community.
Dig deeper into Open source on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Experiment with new directions in software development.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.