官术网_书友最值得收藏!

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:

Installing Modules and Themes

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.

Files

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.

Directories

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.

Note

Under no circumstances should anything ever be added into these directories.

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:

The Sites Directory

Tip

In many FTP clients, you can create new folders by using the context menu that appears when you right-click within the parent directory.

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 drupal.org.
  2. Decompress the theme or module. They are packaged on drupal.org 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 http://drupal.org/project/advanced_help.

Step 1: Download

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 http://drupal.org/project/advanced_help.

Tip

To keep your downloaded code organized, create a folder to use specifically for this purpose.

Step 2: Decompress

Once you have downloaded the code from drupal.org 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 http://www.7-zip.org) 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:

Tip

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

Step 3: Upload

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:

Step 4: Enable

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.

Tip

Many modules are actually a collection of related modules. For example, the Views module comes with three related modules. Before you install 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.

Modules

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:

Modules

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.

Themes

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 Chapter14: Theming and User Interface Design.

Modules and Themes: A Summary

As described in this section, installing modules and themes involves four steps:

  1. Download
  2. Decompress
  3. Upload
  4. Enable

Modules are uploaded into sites/all/modules, and themes are uploaded into sites/all/themes.

Modules, once uploaded, are enabled at admin/build/modules.

Themes, once uploaded, are enabled at admin/build/themes.

Although different modules and themes will have varying configuration settings, the above steps will remain constant for any module or theme you use on your site.

主站蜘蛛池模板: 临江市| 庆安县| 和平区| 临洮县| 莆田市| 喀什市| 罗甸县| 禄丰县| 垦利县| 子长县| 平乡县| 巍山| 西平县| 敦化市| 囊谦县| 翁源县| 九台市| 丹江口市| 阜新| 缙云县| 汝阳县| 仁化县| 基隆市| 隆尧县| 巴林右旗| 永仁县| 常德市| 广东省| 明溪县| 宝清县| 安塞县| 宾川县| 西乡县| 平远县| 松阳县| 闽清县| 灵丘县| 南岸区| 讷河市| 隆子县| 东明县|