Lesson 3: Understanding the Drupal file structureIvan | Mon, 2010-02-15 07:21
It's important to understand the basics of how the directories and files are structured on your Drupal site.
When you install Drupal with the Acquia installer from Lesson 1 or using the files from Drupal.org you will have a default file structure either on your local machine or on your server. If Drupal is installed on your local machine you will find it here:
This is the root of your website. Everything we discuss from here onward will be within this folder.
Within this folder you will find all the files required to run your site. You do not need to know what each files does necessarily, but four sections. These are needed to be able to install new modules or themes and upgrade your site. Let's take a look at them one by one.
Modules are pieces of code that provide different functionality for your site. There are three types of modules.
Core modules can be found in the modules folder within your site's root. These are the modules that provide basic functionality to your Drupal site and they come with your basic Drupal installation.
Contrib modules (user contributed modules) provide extra functionality to your Drupal site. You can choose from thousands of modules on Drupal.org. When you find the module you need you should download the version that matches your version of Drupal. Do not use a module that is still under development unless you're just playing with it. Once you downloaded the compressed file, uncompress it and place it in the following folder: sites/all/modules/.... By default this directory doesn't yet exist so you will have to create it. Your modules will look like this:
Do not put contrib modules next to the core modules. Although they will work that way too it will make upgrades more difficult later.
Once you placed the contrib modules in this folder Drupal will automatically recognize them and you will be able to enable them under the menus Administer/Modules.
Custom modules are required if you can't find the functionality you need within core or contrib modules. In this case you can ask a programmer to write a new module that answers your brief and fits into the Drupal ecosystem of modules. You will place this custom module next to contrib modules.
Similarly to modules there are three different types of themes.
Core themes come with Drupal and they are located under the root in the themes directory.
Contrib themes are available from Drupal.org themes section. Put them into this folder: sites/all/themes. By default this directory doesn't exist so you will have to create it first. These new themes will be recognized by Drupal automatically as well. They can be enabled under the menus Administer/Themes.
Custom themes are themes created by you and should be placed next to contrib themes. In most cases you will create a custom theme, so this is an important subject that we will discuss in great detail in the upcoming lessons.
When you or your users upload any files through the Drupal interface these files will be stored on your server. The files folder will be created automatically and it is located here sites/default/files. You don't need to do anything about these files, but it's important to know where they are located.
When you setup a Drupal site you will have a few settings that make your site functional. These settings are stored in a file here: sites/default/settings.php. When you install your site with Acquia or Drupal installer this file and the settings inside will be done automatically for you. It's important to keep this file safe because it includes the passwords for your Database database.
Congrats, you now know the basic file structure of Drupal.
Commenting on this Blog entry is closed.