
Customizing Drupal - Part 2 Modules and Themes
Drupal Customization - Themes, Modules, and Blocks
Now that we have the base of our site set up, it is time to make the site look pretty, and add some functionality. In this tutorial, we set up our default folders for themes and modules, and I'll show you how to enable them, and modify their settings.
First, we need to understand some of the file structure of Drupal on the server. Drupal's base install sites under our /var/www folder, for our purposes. If you do a ls to list the contents of the directory in /var/www you will notice that there is a themes directory, and also a modules directory. This is not where you put your downloaded themes and modules. I repeat, do not put your downloaded themes and modules in these directories.
Why you ask? Because this is where the core modules and themees for drupal go, we want to create different folders for things that we add on. That way, later when you upgrade from Drupal 5.3 to Drupal 5.4, you do not have to worry about overwriting the modules and themes you have already downloaded, you can simply copy and paste the new install right into your root directory. If this is confusing, then for now, just trust me, and do not put your new themes or modules in these folders.
Where do you put them then? Great question! If you remember back to an earlier tutorial, when we modified our settings.php file, it was located in /var/www/sites/default
Anything you put in that default folder, will be applied to your default drupal installation. In our case, that is our ONLY drupal installation, so we can now make new directories under the default folder called themes and modules
**note to advanced users. If you had multiple sites and wanted them all to share fromt he same themes and modules, you can put these directories under /var/www/sites/all and they will be available to all sites you create on this server.**
So, lets make those directories
sudo cd /var/www/sites/default
sudo mkdir themes
sudo mkdir modules
Congrats! You now have directories where you can download additional functioinality for your site! Now, obviously, if you want to add a module to Drupal, you will put it in the /var/www/sites/default/modules folder, and if you want to add a theme, you will put it in the /var/www/sites/default/themes folder. But where do we get new themes and modules?
Drupal.org of course. Once there, you will see a downloads block at the top right of the page. Click on either modules or themes. You may be overwhelmed, because one of the most amazing thing about drupal, is how many contributed modules there really are. You can do just about anything with the modules that are provided for free right off Drupal.org. If you go ahead and sign up for an account, you can also filter by what version of Drupal you are running, which in our case is 5.
Here is a list of modules that I used to create linuxbasement.com
- audio
captcha
captcha_pack
cck (this is a must)
dhtml_menu (another must)
fckeditor (this one requires some additional configuration, but it provides the editor for when you post in the forum, or comments, and so on)
imagefield
imce
jstools
pathauto (must!)
private (I create design notes and tutorials and keep them private until I'm ready to publish)
views (MUST)
views_bonus
To download and install a module, you have to change to the directory, and then wget them into your modules folder. Then untar the file, and then go into drupal to enable the module. **note, if you administering drupal on a remote server via ftp, you could download these modules to your machine, put them in the folder, and then ftp them up to your server**
So, lets try this, I will use the audio module as an example. This enables a user to upload and play music or podcasts right on their site. Find the module in the downloads section of the drupal.org site. Find the direct download link, and right click on it, and do copy link location. Then we can copy and paste that url into our wget in the command line. So do the following in the command line:
cd /var/www/sites/default/modules
sudo wget http://ftp.drupal.org/files/projects/audio-5.x-1.3.tar.gz
You should see the file successfully download. Now lets untar it.
sudo tar xfvz audio-5.x-1.3.tar.gz
That will untar the file right into your modules directory. That's it! Now all you have to do is go over to your web browser and enable the module in Drupal. Lets do that now!
Open your browser and navigate to the administer-->site building-->Modules page. Or go directly at http://localhost/admin/build/modules
Here you will see all of your modules for the site. You can enable and disable them, and play around with them as much as you'd like. For now, lets look for our new audio module. You should see it right at the top of the list, since they are sorted alphabetically by category. You will notice that some of the core functionality of the audio module relies on the Views module which i listed earlier. Go ahead and download and untar Views, and then come back here and enable both modules. Good luck!
Now that we have a few modules installed, lets go ahead and pick a theme. Head over to drupal.org again, and go to the themes download page. Again, make sure you are downloading a theme for drupal 5. Once you find your theme, we are going to go through very similar methods of downloading and installing. Right click on the direct download and do "copy link location". Now head to the command line and get into our newly created themes directory.
sudo cd /var/www/sites/default/themes
sudo wget (whatever theme you want to download direct URL)
sudo tar xfvz (the file you just downloaded)
This will change to your themes directory, download the theme you have chosen, and untar it to your directory. Please note that you need to substitute the direct location of the them you want to download above, and do not use the brackets.
Now navigate on over to your Administer-->Site building-->Themes page, or go directly to http://localhost/admin/build/themes and you will see a list of themes. Several themes are installed by default, but you should also see the them you just downloaded in this directory. Go ahead and check enabled, and default. You should see the theme take over! How simple was that??

You will notice there is now a configure button next to your enabled theme, go ahead and click on it. Here you can configure many aspects of your theme, including uploading your custom banner and choosing some formatting options of your site.
You now have the power of Modules and themes in your grasps. You can administer the settings of you modules over at the administer by module page, http://localhost/admin/by-module which will give you a lot of control over your modules. Give it a try. Also take a look at blocks and Menus in preperation for our next tutorials.
