Installing Modules and Themes

As you run and administer your Drupal site, you will need to install and enable different contributed modules and themes. To understand how to install contributed modules and themes, we will need to take a brief look at Drupal's directory structure as pictured in the following screenshot:

Remote Site; | /var/www/html/drupal6_

El Ö drupal6 HS) includes •••03) misc HS) modules E Ö profiles - scripts S Ö sites H£j& themes

Filename / Filesize! Filetype Last modified Permissions Owner / Group

ö includes File Folder 7/6/2008 11:09,,, drwxr-xr-x vuser

Qmisc Rle Folder 7/6/2008 11:09.,, drwxr-xr-x vuser modules ■ ■ a ■ ■ Rle Folder 7/6/2008 11:11,,, drwxr-xr-x vuse

£j)profiles Rle Folder 7/6/200811:11,,, drwxr-xr-x vuse

^(scripts Rle Folder 7/6/200811:11,,, drwxr-xr-x vuse

ö sites File Folder 7/6/2008 11:11,,, drwxr-xr-x vuser

Q themes^fci ■ ■ ■ File Folder 7/6/2008 11:15,,, drwxr-xr-x vuse

§,htaccess 3,488 HTACCESS ,,. 7/6/2008 11:09,,, -rw-r-r- vuse lj0CHANGELOG.txt 37,150 TextDocu... 7/6/2008 11:09,,, -rw-r-r- vuse

ID COPYRIGHT.bit 981 TextDocu... 7/6/2008 11:09,,, -rw-r-r- vuse

|^]cron_new,php 262 PHP File 7/6/200811:09,,, -rw-r-r- vuse index, php 980 PHP File 7/6/200811:09,,, -rw-r-r- vuse

0 INSTALL.mysql.txt 1,308 TextDocu... 7/6/2008 11:09,,, -rw-r-r- vuse

0 INSTALL.pgsql.txt 1,075 TextDocu... 7/6/2008 11:09,,, -rw-r-r- vuse install.php 45,837 PHP File 7/6/2008 11:09,,, -rw-r-r- vuse

(D INSTALL.txt 14,744 TextDocu... 7/6/2008 11:09,,, -rw-r-r- vuse

ID LICENSE.tort 18,064 TextDocu... 7/6/2008 11:09,,, -rw-r-r- vuse

(jO MAINTAINERS.txt 1,978 TextDocu... 7/6/2008 11:09,,, -rw-r-r- vuse

(jp robots.txt 1,627 TextDocu... 7/6/200811:09,,, -rw-r-r- vuse

^update,php 25,244 PHP File 7/6/200811:09,,, -rw-r-r- vuse

(jO UPGRADE.txt 5,002 TextDocu... 7/6/200811:09,,, -rw-r-r- vuse l&jxmlrpcphp 352 PHP File 7/6/200811:09,,, -rw-r-r- vuse

15 files and 7 directories. Total size: 158,092 bytes

As seen in the preceding screenshot, the directory structure contains seven directories, in addition to 15 files in the base folder of the Drupal install.


On looking at the files in the base folder of the Drupal install, we will see three different types of files: an .htaccess file, a series of .txt files, and a series of .php files. The .htaccess file contains specific settings that help ensure that your site runs smoothly; the .txt files (with the exception of robots.txt) all contain information about Drupal, and the .php files are all part of the codebase that allows your site to run.

For most sites, you will never need to open or edit any of these files. Of all the files in the base directory of your Drupal install, the only two that could ever require editing are the .htaccess file and the robots.txt files. However, tweaks to these files should only be done when absolutely necessary and you should always back up these files before attempting any modifications to them.


On looking at the directories of the Drupal install, we will focus on three directories: modules, themes, and sites.

Core Modules and Themes

The modules and themes directories of the core Drupal install, indicated by the dashed arrows in the preceding screenshot, contain the core modules and themes.

[r'&rX Under no circumstances should anything ever be added into these I

Nij;^ directories. I

The Sites Directory

The sites directory, indicated by the solid arrow in the preceding screenshot, contains the directories into which we install additional modules and themes. The default Drupal installation, as shown in the following screenshot, comes with two sub-folders in the sites directory: all and default.

The default directory contains our settings.php file; the all directory is where we will put contributed themes and modules.

To start, we need to create themes and modules directories in sites/all, as pictured in the following screenshot:

[->K\ In many FTP clients, you can create new folders by using the context I

menu that appears when you right-click within the parent directory. I

Once you have created these folders, you are ready to install modules and themes.

Adding Modules and Themes: The Steps

To add a module or a theme, follow these four steps:

1. Download the theme or module from

2. Decompress the theme or module. They are packaged on as tar.gz files, and need to be extracted before they can be installed.

3. Upload the theme or module to your site.

4. Enable the modules at admin/build/modules or the theme at admin/build/themes.

Step 1: Download

All modules and themes are downloaded from their project page. In this example, we will download and install the Views module and the Advanced Help module. To get the source code, we will navigate to the Views project page at http://drupal. org/project/views as shown in the following screenshot, and also the Advanced help project page at

s> Download - Modul

_| View | [ Edit 1 f Outline ] [ Revisions ) [ CVS access merlinofchaos - November 25, 2005 - 12:34

Content display ■ Vie<

The views module provides a flexible method for Drupal site designers to control how lists of content (nodes) are presented. Traditionally, Drupal has hard-coded most of this, particularly in how taxonomy and tracker lists are formatted.

This toot is essentially a smart query builder that, given enough information, can build the proper query, execute it, and display the results. It has four modes, plus a special mode, and provides an impressive amount of functionality from these modes.

You need Views if:

* You like the default front page view, but you find you want to sort it differently.

* You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.

* You use /tracker, but you want to restrict it to posts of a certain type.

* You like the idea of the 'article' module, but it doesn't display articles the way you like.

* You want a way to display a block with the 5 most recent posts of some particular type.

* You want to provide 'unread forum posts'.

* You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.

Views can do a lot more than that, but those are some of the obvious uses of Views.


Official releases Date


Official releases Date



2.67 MB


■ Release notes ■


Recommended for 6.x




207.36 KB


■ Release notes •


Recommended for 5.x




169.88 KB


■ Release notes •


Recommended for 4.7.x

The Views project page shows only the official releases; other project pages frequently show development snapshots. The Status column, indicated by Item 1 in the preceding screenshot, gives you information about the different versions that are available. In most cases, you should only use official releases that have a status of Recommended. Also, the version of the module needs to match up with the version of Drupal; for example, only the 6.x versions of modules work with Drupal 6.

In this case, we want to install Views for Drupal 6, so we click the Download link, indicated by Item 2 in the preceding screenshot, to download the module.

Then, repeat these steps for the Advanced help module at

I To keep your downloaded code organized, create a folder to use I

I v) specifically for this purpose. I

Step 2: Decompress

Once you have downloaded the code from to your computer, decompress the file. On a Mac or Linux machine, this will occur automatically; on a PC, use 7-zip (an open-source utility available at to decompress the tarball into the Views directory.

Step 3: Upload

Open your FTP client, and upload the directory containing the module (in our case, Views) to the sites/all/modules directory as shown in the following screenshot:

If you were uploading a theme, you would upload the theme folder into sites/all/themes directory.

If you were uploading a theme, you would upload the theme folder into sites/all/themes directory.

Step 4: Enable

Once the modules have been successfully uploaded into your sites/all/modules directory, click the Administer | Site Building | Modules link, or navigate to admin/build/modules as shown in the following screenshot:

This screen gives a breakdown of the modules that you have uploaded into your sites/all/modules folder.

To enable the Advanced help module, select the checkbox next to Advanced help. To enable the Views module, select the checkboxes next to the Views, Views exporter, and Views UI modules. Click the Save configuration button to save your settings and enable your modules. You will receive a confirmation message at the top of the screen.

Many modules are actually a collection of related modules. For example, the Views module comes with three related modules. Before you install -Q any module, you should read the README.txt and the INSTALL.txt files that come with most modules. These files are usually located in the base directory of the module download.

Configuring Modules and Themes

Now that we have finished installing modules and themes, we need to configure them.


Once you have enabled a new module, you should check to see if there are any configuration options for the module. To do this, navigate to the main administration page, either by clicking Administer, or by navigating to admin. Then, click the By module tab as shown in the following screenshot:

Administer | Packt and Dru pal - Mozilla Firefox


| File Edit View

History Bookmarks Tools Help


+ i



] • 1 ini_set php memory limit





y fe*

Packt and Drupal

Home > Administer

[ Packt and Drupa if

Home > Administer

Search this site:


° My account l> Create content ° Recent posts V Administer

» Content management i> Site building O Site configuration t> User management l> Reports o Advanced he!p ° Help o Log out

Administer By task

This page shows you all available administration tasks for each modufe.

Advanced heip

Allow advanced help and documentation. ° Configure permissions

Enables keeping easily and regularly updated user web pages or blogs.


Controls the boxes that are displayed around the main content.

° Configure permissions 0 Blocks ° Get help

° Configure permissions ° Get help


Allows u. outline.

s to structure site page;

Alio i.

s to comment o s published content.

° Configure permissions ° Comments o Get help

° Configure permissions o Books ° Get help nistrators to define

http : //www. alphabe tademo. com/drupal6/

By looking at the page, we see that both the Views module and the Advanced help module have links to Configure permissions. These permissions are covered in more detail later in this chapter, in the Creating Views section.


After you have uploaded a theme into the sites/all/themes directory, you will need to enable it via the Administer | Site Building | Themes link, or by navigating to admin/build/themes. Themes and their different settings are covered in more detail in Chapter 14: Theming and User Interface Design.

0 0

Post a comment