Brought to you by molecularsciences.org.
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.
This publication may not be redistributed without this notice.

Drupal

A Content Management System - CMS is a collection of tools designed to allow easy creation, modification, organization and removal of content from a web site.

The problem

The majority of websites today cannot be maintained by a notepad with HTML for the following reasons:

Difficult Decision

It is easy to understand why a CMS is needed and upon this understanding, logical do decide to use a CMS. However, choosing a CMS which suits your needs is a much more difficult decision. There are plenty of content management systems out there. Most of them support the essential features that a CMS is expected to have but they all differ greatly in terms of their usability, extensibility, and support. A common trick to go around this problem is to ask seasoned webmasters or industry gurus. Surely, they would give you the right answer. Unfortunately, the answer you would get would depend largely on who you ask. People are usually accustomed to the CMS they use and are often unwilling to try something new or move to another CMS, unless they come across serious issues. Therefore, they usually end up recommending what they use themselves.

Among the various content management systems, Drupal and Joomla! stand out as the two most widely used. Drupal is the preferred choice of programmers, coders, geeks, and anyone who seeks absolute control over their CMS. Joomla! is preferred by web designers and anyone who seeks a powerful and easy to implement solution with emphasis on a great looking website. Joomla! does have superior design and template functionalities.

Go for Joomla! if

Go for Drupal if

How about a specialized CMS


Most people who have worked on CMS development realize that one size doesn't fit all. Which is why there are several specialized content management systems which concentrate on precise tasks. For example, coppermine concerns itself with photo galleries. Moodle is designed exclusively for elearning.

Conclusion


The content management system technology is essential, inexpensive, efficient, powerful and mature. It should also be noted that not all content management systems can fulfill you needs. A CMS must be chosen prudently. After reading this page, if you still think that drupal is the right solution for you, then read on. Otherwise, I wish you luck with whatever other technology you use to achieve your objectives.

Installing Drupal on Linux

First of all, go to http://www.drupal.org and copy the link for Drupal 6. At the time of writing, Drupal 6.16 is available. Then type the following in the terminal:

$ wget http://ftp.drupal.org/files/projects/drupal-6.16.tar.gz

Unzip the files to you directory of choice. The following code would unzip to the directory /var/www/html.

$ tar xzvf drupal-6.16.tar.gz -C /var/www/html

You should see a directory called drupal-6.16. Rename it to a name of your choice. This name would be visible in your URL if you use the default settings.

$ mv drupal-6.16 web

Open a web browser and type the following address in a web browser

http://localhost/web/index.php

You would see a web page with the an error message saying "Copy the ./sites/default/default.settings.php file to ./sites/default/settings.php." and another error message saying "The directory sites/default/files does not exist.". Do the following:

$ cd /var/www/html/web/sites/default/
$ cp default.settings.php settings.php
$ chmod 777 settings.php
$ mkdir files
$ chmod -R 777 files

Refresh the screen and the errors would be gone. The next screen would request your database name, user name and password. Assuming, you haven't created a database, do the following:

$ mysql -u root -p

Type your password to log into MySQL DB.

mysql> create database drupal;
mysql> create user drupal_user;
mysql> grant all on drupal.* TO 'drupal_user'@'localhost' IDENTIFIED BY 'xxxxxx';
mysql> flush privileges;

For the web form, the database name is 'drupal', user name is 'drupal_user' and the password is whatever you typed in place of 'xxxxxx'.

Drupal installed and ready to use. Change the permissions on settings.php to 755.

$ chmod 755 settings.php

Setting up drupal on microsoft windows

Since drupal requires Apache, MySQL, and PHP. Most people new to drupal usually do not have Apache, MySQL and PHP installed and properly configured. Therefore, I would cover their installation and configuration as well. So Let's begin:

Setting up Drupal on Windows

You can either install a pre-built package such as the one offered at devside.net or set up your own system. The pre-built versions are usually up an ready in a few minutes but give much less flexibility and you panic every time you encounter even a minor configuration issue. Setting up your own system is much more rewarding as you learn more about your system and also end up with a system which suits your needs better.

If you wish to use the pre-configured package, available at devside.net, go to http://drupal.org/node/195238 for installation instructions.

To build your own system, continue reading.

Installing Apache on Microsoft Windows

Here I describe installation and configuration of Apache 2.2.6. These instructions should be valid for version 2.0.x and above.

Download

1. Go to http://www.apache.org/dist/httpd/binaries/win32/
2. Choose a mirror.
3. Click on the latest MSI Installer Package release. Something like apache_2.2.6-win32-x86-no_ssl.msi

Installation

1. Double-click on the .msi file you downloaded
2. Click on next
3. Accept license and click on next
4. In the Server Information window, input the following:
Network Domain: localhost
Server Name: localhost
Admin Email: admin@localhost
Check for All Users, on Port 80, as a Service and click on next
5. Choose Typical and click on next
6. Click on change and change Installation directory to c:\Apache2.2\
7. Click on next and Install

Starting stopping and restarting Apache

After the installion, Apache2 starts automatically. You should also see the start icon in the system tray. It is composed of a feather and the play symbol. You can click on this icon to start, stop or restart Apache. Alternately you can go to:

Start > All Programs > Apache HTTP Server 2.2.x > Control Apache Server

From here you can choose to start, stop, or restart Apache. Once, you install your server, I recommend that you restart the server to see if there are any errors.

The requested operation has failed!
If you get "The requested operation has failed!" error, then you need go to

Start > All Programs > Apache HTTP Server 2.2.x > Configure Apache Server > Test Configuration

to find the error. If nothing else works, uninstall and reinstall Apache.

Another Apache service is already running
You get this error message when you have multiple installations of apache. Several pre-configured server packages such as the one provided by http://www.devside.net install Apache. The easiest solution is to remove other apache installations. If you, however, wish to have multiple copies, you can go to http://www.heritage-tech.net/336/setting-up-multiple-apache-local-web-si... to get some guidance.

Checking Apache error log

To check Apache error log, you need do the following:

Start > All Programs > Apache HTTP Server 2.2.x > Review Server log File > Review Server Log

All errors generated by Apache are logged in this file.

Testing the installation
Open your browser and type: http://127.0.0.1/ or http://localhost/. If you see the words "It works!", then your server is up and running. If it doesn't, then restart Apache service and try again.

Pointing Apache to your files

By default, Apache points to c:\Apache2_2\htdocs, where c:\Apache2_2 is the installation directory we defined earlier. Suppose we would like to create out website at c:\www, we would have to point Apache to this address. To do so, we need to edit the httpd.conf file. There are two ways to to this. We can either go to:

Start > All Programs > Apache HTTP Server 2.2.x > Configure Apache Server > Edit the httpd.conf Configuration File

or simply open c:\Apache2_2\conf\httpd.conf with notepad.

Before you modify httpd.conf, you MUST create a backup copy of this file.

1. create folder c:\www
2. create an html file called index.html inside c:\www
3. Place the following html inside index.html

<html><body>I see you</body></html>

4. Search for DocumentRoot.
5. Put a '#' symbol in front of DocumentRoot "c:/Apache2_2" to comment it out
6. Type DocumentRoot "c:/www" underneath this line.
7. Search for <Directory "c:\Apache2_2\htdocs">
8. Put a '#' symbol in front of <Directory "c:\Apache2_2\htdocs"> to comment it out
9. Type <Directory "c:\www"> underneath this line.
10. Restart Apache service
11. Type http://localhost.

If you see you "I see you", you are in business. If it didn't work, go back to httpd.conf and make sure that you made the right modifications.

Installing PHP5 on Microsoft Windows

Here I will show how to install PHP and configure it with Apache. I am using Apache 2.2.6 and Windows XP. I would be installing PHP 5.2.5. It is assumed that you have read Installing Apache on Microsoft Windows.

1. Download PHP
PHP can be downloaded from http://www.php.net/downloads.php. Get the latest Windows Binary zip package for Apache. It should be something like php-5.2.x-Win32.zip.

2. Unpack PHP distribution
- Unzip to c:\php.
- Create a copy of c:\php\php.ini-dist and rename it to c:\php\php.ini.

3. Edit php.ini
- Edit php.ini file with notepad
- Comment out doc_root with ;
- Type doc_root = "c:\www" in the line just underneath. This address corresponds to the value of DocumentRoot in httpd.conf file of Apache. If you have set it to another value, use it instead of c:\www.
- Comment out extension_dir with ;
- Type extension_dir = "c:\php\ext" in the line just underneath.

Editing httpd.conf file
httpd.conf file is used to configure Apache. Go to

Start > Apache HTTP Server 2.2.6 > Configure Apache Server > Edit the Apache httpd.conf Configuration File

At the end of the file, type the following:

# Configuring PHP5 for Apache
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/php"

- The first line specifies the location of the .dll file which links Apache to PHP. Depending on your software version the name of the file would be different. However, it should have the format php5apache2_x.dll. Use the filename found inside your c:\php folder.
- The AddType directive specifies which mime type should be used for a given file extension
- PHPIniDir specifies the location of your php.ini file

- Do to DirectoryIndex found inside tag. Add index.php to DirectoryIndex. It should look something like:

<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

Order matters. Since index.php is placed before index.html, if both files were type, index.php would be displayed by default. So if you just type, http://localhost, index.php would display. If it doesn't exist, index.html will be displayed.
Moment of Truth
Create file c:\www\index.php. Inside write some PHP code such as print "hello"; and save it. Restart Apache. Type http://localhost or http://localhost/index.php to see your file. If you see the code instead of the output, double check your modifications to the .ini files.

Installing MySQL5 on Microsoft Windows

I am using:

- Apache 2.2.6,
- PHP 5.2.5
- Windows XP
- web server root is c:\www

The instructions on this page are valid for MySQL 5.0 and higher.

1. Download MySQL
You can download mysql from http://dev.mysql.com/downloads/mysql/5.0.html#downloads . I have an AMB 64-bit processor but Windows XP is 32bit. So I could not use the 64 bit version. So I downloaded Windows ZIP/Setup.EXE (x86).

2. Unzip Software
Once the software is downloaded, you can unzip it anywhere you want.

3. Install & Configure
- double click the .exe file to start installation
- next
- choose custom
- next
- next
- install
- next
- next
- finish
Installation is complete. The configuration wizard would open automatically.
- next
- choose detailed configuration
- next
- choose developer machine
- next
- choose multifunctional database
- next
- next
- choose manual setting
- choose concurrent connections 10
- next
- next
- choose Best support for multilingualism
- next
- next
- type root password
- next
- execute

Worst Nightmare
Your worst nightmare in MySQL is to get the following error message:

can't connect to MySql server on 'localhost' <10061>

If you check the blogs, you will find hundreds of people crying for help and various different proposed solutions. The reason is the this error can occur due a whole range of problems. Finding out what exactly caused this error can be a challenge. I had to turn off my avast antivirus. Once installation was complete, I turned avast back on and everything worked fine.

Moment of Truth
Go to:

Start > MySQL > MySQL Server 5.0 > MySQL command line client

Type the password you defined. Type show databases;. If you don't get errors, your MySQL is running.

Configuring PHP to communicate with MySQL

Here I would show you how to configure your PHP with MySQL. I am using:

- Apache 2.2.6,
- PHP 5.2.5
- MySQL 5.0.25
- Windows XP
- web server root is c:\www

It is assumed that you have read the previous three articles where I show how to install Apache, install PHP, configure Apache and PHP to communicate with each other and install MySQL.

I have installed PHP on c:\php and the Apache document root is c:\www.

Configuring PHP for MySQL

To configure PHP to communicate with MySQL, we need to edit the php.ini file which, on my computer, is located at c:\php\php.ini.

Edit php.ini
First of all create a backup copy of php.ini. Then edit it to remove the semicolon from

;extension=php_mysql.dll

This would uncomment this line. On my computer, php_mysql.dll file is located at c:\php\ext\php_mysql.dll. This directory is defined in php.ini file:

extension_dir = extension_dir = "c:\php\ext"

Please verify that php_mysql.dll is actually residing at this address. If it is not, then with change this address to where it is located or copy the file to this folder. Otherwise you will get an error like 'cannot connect to mysql_connect()'.

Setting system path
Once you have made this simply but crucial modification, you need to add the php directory to the system path:

Start > Control Panel > Advanced > Environment Variables > System Variables > Path > Edit

Go to the end of the line and append ;c:\php. You need to restart your computer for this to take effect. Once your computer is restarted, go back to verify that the change is permanent.

Testing Configuration

Now we need to test if we can access the database from the web.

Start MySQL client
Start MySQL:

Start > All Programs > MySQL > MySQL Server 5.0 > MySQL Command Line Client

type your password

Create New User
You do not want to give root access to a web client, so we need to create a new user account with limited privileges; select, insert, update, and delete on one database called test.

mysql> create user 'web_user'@'localhost' identified by 'password';
mysql> grant select, insert, update, delete on test.* to web_user identified by 'password';

Create and fill MySQL table
We need to create a table with dummy data to use for testing purposes. First we choose database. Then we create a table. Finally, we fill in some data.

mysql> use test;
mysql> create table person (id int primary key auto_increment, name varchar(30));
mysql> insert into person values (null, 'Alice');
mysql> select * from person;

Write PHP script

<?php
$con = mysql_connect("localhost", "web_user", "password") or die(mysql_error());
mysql_select_db("test",$con) or die(mysql_error());

$q = "SELECT * FROM person";
$rs = mysql_query($q);

while ($field = mysql_fetch_array($rs))
{
$id = $field['id'];
$name = $field['name'];
print 'ID: ' . $field['id'] . ' - Name: ' . $field['name'];
}
}
?>

Save this file as mytest.php inside c:\www\ folder. Reminder c:\www is the Apache document root.

Run the test
Now open your browser and type http://localhost/mytest.php. You should see ID:1 - Name:Alice.

Installing and configuring phpMyAdmin

Using MySQL from a commandline client is often not very convenient. Luckily there are several graphical clients. Perhaps the best one and certainly the most widely used is phpMyAdmin. It is freely available on the Internet. In this article, you would see how to install and configure phpMyAdmin to work with MySQL. If you experience troubles with these instruction, you might want to read the previous few articles. I am using:

- Apache 2.2.6,
- PHP 5.2.5
- MySQL 5.0.25
- Windows XP
- web server root is c:\www

1. Download phpMyAdmin
phpMyAdmin can be downloaded from here. Download the latest stable version without the -rc in the file name. Something like phpMyAdmin-2.11.2.2-english.zip.

2. Unzip inside web root
Unzip inside the web root. My web root, as defined in httpd.conf file, is c:\www. After unpacking, my directory should look like c:\www\phpMyAdmin\contrib\... You would have to rename phpMyAdmin-2.11.2.2-english to phpMyAdmin.

3. Set up config file
If you have a file c:\www\phpMyAdmin\config.inc.php, back it up. If you don't, create a new file with this name. Copy-paste the following code into this file. Add your password in place of PASSWORD. It appears twice in the file.

/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use scripts/setup.php
*
* All directives are explained in Documentation.html and on phpMyAdmin
* wiki .
*
* @version $Id: config.sample.inc.php 10142 2007-03-20 10:32:13Z cybot_tm $
*/

/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = '';

/*
* Servers configuration
*/
$i = 0;

/*
* First server
*/
$i++;

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'PASSWORD';

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'PASSWORD';
/* Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';

/*
* End of servers configuration
*/

/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

Save this file.

Run phpMyAdmin
Open you browser and type http://localhost/phpMyAdmin

Installing Drupal on Microsoft Windows

Here I will show how to install drupal. I am using:

- Apache 2.2.6,
- PHP 5.2.5
- MySQL 5.0.25
- Windows XP
- web server root is c:\www

These instructions are valid for drupal 5.0 and above. I am installing drupal 5.5.

Download and extract drupal

Drupal can be downloaded from drupal.org. Once downloaded, extract the contents of the zip file.

Copy to web server root folder

The web server root is the address where a web server such as Apache look for files it is supposed to show on the Internet. If you do not know your web root, look into your httpd.conf file. It should be inside your Apache installation directory. Open this file and look for a line that looks like:

DocumentRoot "c:\www"

The web server root is c:\www. Create a folder called drupal at this address. Copy the contents of the extracted folder inside this folder. Once done, it should look as follows:

  • c:\www\drupal\modules\
  • c:\www\drupal\themes\

Prepare database for drupal

Create a database called drupal. Create a user called drupal_user. Grant full access on drupal to drupal_user from localhost. Replace xxxxxx on the third line with a password.

mysql> create database drupal;
mysql> create user drupal_user;
mysql> grant all on drupal.* TO 'drupal_user'@'localhost' IDENTIFIED BY 'xxxxxx';
mysql> flush privileges;

Run drupal

In your browser, type http://localhost/drupal/. Your should get a page asking you to type database information. Type in the information you just type in mysql command line.

Installation problems in drupal 5.5

If you get an error message at http://localhost/drupal/, edit your settings.php file. If you still get errors, check the configuration of your Apache. Refer to previous tutorials in this series for more information.

Edit settings.php file

Settings.php file contains installation configuration information. To edit settings.php file open it with notepad. It is located at:

c:\www\drupal\sites\default\settings.php

Change

$db_url = 'mysql://username:password@localhost/databasename';

to

$db_url = 'mysql://drupal_user:password@localhost/drupal';

Replace the password with the password you chose in the previous step.

Notices

Following is a common error message:

Notice: Trying to get property of non-object in C:\www\drupal5\includes\form.inc on line 325
Notice: Undefined variable: redirect in C:\www\drupal5\includes\form.inc on line 268
Notice: Undefined variable: base in C:\www\drupal5\includes\form.inc on line 465
Notice: Undefined index: #value in C:\www\drupal5\includes\form.inc on line 1045
Notice: Undefined index: #value in C:\www\drupal5\includes\form.inc on line 1045
Warning: Cannot modify header information - headers already sent by (output started at C:\www\drupal5\includes\form.inc:325) in C:\www\drupal\includes\common.inc on line 141
Notice: Undefined variable: no_module_preprocess in C:\www\drupal5\includes\common.inc on line 1472
Notice: Undefined variable: no_theme_preprocess in C:\www\drupal5\includes\common.inc on line 1493

These errors are due to php.ini configuration. PHP notices are harmless but they can sometimes generate "headers already sent" errors. These errors would hinder installation of drupal. The solution is to configure PHP to not display notices. Edit your php.ini and set error_reporting to as follows:

error_reporting = E_ALL & ~E_NOTICE

Restart Apache and you should be back in business.

Configuring Drupal

Once drupal is installed, you should configure is before you do anything else. The few articles would guide you through drupal configuration.

What to do when you locked yourself out of drupal

When you set site maintenance to offline, you lose the link to you login form as well. To get the login form, you need to do the following:

http://www.mysite.com/q=user
  or
http://www.mysite.com/user

Do not replace the word user with your username.

If this doesn't work, log into your database and type the following SQL commands.

UPDATE variable SET value = 's:1:"0";' WHERE name= 'site_offline';
DELETE FROM cache WHERE cid = 'variables';

If you lost your mysql password, go to your drupal installation directory. Then navigate to sites/default. You should see a file by the name of settings.php. Open this file and look for a line which looks like the following.

mysql://username:password@localhost/databasename

Then type the following:

mysql -u username -p databasename

You will be prompted for you password. Once logged in type the SQL commands listed above.

Setting up clean URLs

Drupal URLs have the format http://www.molecularsciences.org/?q=node/11. '?q=' does not look very nice in the URL. It also hinders using meaningful URLs. Search engines such as google and yahoo prefer clean URLs. To enable clean URLs:

Administer > Site Configuration > Clean URLs > Run the clean URL test

You should get a message like follows:

"This option makes Drupal emit "clean" URLs (i.e. without ?q= in the URL.) You have successfully demonstrated that clean URLs work on your server. You may enable/disable them as you wish."

If you get this message:

Enabled > Save Configuration

Troubleshooting

If you do not get the desired results from the Run the clean URL test, you need to modify your .htaccess file located in your drupal root folder. My drupal root is located at c:\www\drupal :

  1. Backup your .htaccess file
  2. Uncomment RewriteEngine on
  3. Add Options All in the following line
  4. Uncomment RewriteBase /drupal. If you drupal root is not 'drupal', change it your drupal root.
  5. Uncomment the following lines and save the file

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

What do these odd three lines of code actually do.
1. If requested file exists, serve it.
2. If requested directory exists, serve it depending on how index option is configured.
3. Otherwise, send all requests to index.php, setting parameter ‘q’ as the path of the original request, and then append the rest of the query string.

Following is what my .htaccess file looks like. If nothing else works, try copy pasting this:

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
# Do not cache dynamically generated pages.
ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
Options All

# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
RewriteBase /drupal

# Rewrite old-style URLs of the form 'node.php?id=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^id=([^&]+)$
RewriteRule node.php index.php?q=node/view/%1 [L]

# Rewrite old-style URLs of the form 'module.php?mod=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
#RewriteRule module.php index.php?q=%1 [L]

# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# $Id: .htaccess,v 1.81.2.3 2007/09/21 12:24:22 drumm Exp $

Restart Apache so that the changes can take effect.

Error Reporting

There are various different errors that can be generated by a website. Apache errors (mostly 403 and 404), SQL errors, and PHP errors. A 403 error is generated when access to a page is denied. A 404 error is generated when a page is not found on the server. All errors are logged in an error log. In drupal, we can define custom pages for 403 and 404 pages.

First we would create a page for 404 errors. To create a page:

- Create content > Page
- For title, type "Page not Found".
- For body, type a custom error message such as "The page you request cannot be found, please re-check the URL"
- Click on the "Publishing options" link at the bottom and make sure that the "Published" checkbox is checked.
- Click on submit

Now look at the url. You would see something like node/1. Jot down this number somewhere.

Now go to:

Administer > Site Configuration > Error Reporting

In the first field, type user. This would redirect the visitor to the log in page whenever, he comes across a page he does not have the rights to access.

In the second field type node/1 or whatever you jotted down from the previous step.

The rest should be pretty self-explanatory.

Input formats

Input formats define a way of processing user's text. The input is stored as text. Filters are applied before the text is displayed on a web page. Every input format is a set of filters which are applied to the text. For example, a filter can replace return with <br> tags or convert a URL into a link. Users can choose an input format before submitting content.

You can also define you own custom input formats. To define a new custom format:

Administer > Site configuration > Input formats > Add input format

- Type a name for your filter
- Choose Roles
- Choose Filters
- Save configuration

Defining Website Information

Basic information about the site can be defined in the site information page.

Administer > Site configuration > Site information

Here you can define the site name, slogan, mission and footer.

Anonymous user is a user who posted something without logging in. It is usually not good idea to allow anonymous users to post on your site. You would soon find yourself under attack from spambots. If you do allow anonymous posts, the name you specify here would appear as the author. I usually change this field to a blank screen.

You can also define the address of the front page. By default, it is node which lists the latest published articles. Very often, we would like it to be something different. To change it, simple type in the address of the desired page. Do not, however, type in the url alias.

Site information is often theme specific, so you need to configure your theme as well:

Administer > Site building > Themes > Configure

Themes are website designs. Drupal offers you a wide variety of themes to choose from. Changing a theme (look and feel of the entire website) is as easy as changing gears in a car. You can either use global configuration which affects all themes or make theme-specific configuration. Here we would mind ourselves with global configuration.

Here you define what would be visible and what would not be. In the Toggle display section, you define whether you want to make the logo, site name, slogan, mission, or shortcut icon to appear. Shortcut icon is the small icon which appears before the url. In the Logo image settings sections, you can upload your logo. The default logo is the logo provided by the theme. A similar section, Shortcut icon settings also exists for shortcut icon.

The user information is the name of the author, date and time of publication of a post. If you check the checkbox, this information would appear. I usually do not like to show this information and therefore uncheck these boxes in the Display post information on section.

The current theme's configuration overrides the global theme configuration. If you wish to use the global theme's configuration, click on your current theme (garland in my case) and click on Reset to defaults to use the global configuration.

Themes

A theme is a collection of files which together determine the look and feel of a drupal web site. Themes are available for free or a small price on the Internet.

Downloading Drupal Themes

Themes can be found at http://drupal.org/project/Themes. Suppose we want to download the art4 blue theme. Drupal themes and modules are available as zipped tar files. On Unix, you do the following:

$ wget http://the-site/theme.tar.gz
$ tar -xzvf theme.tar.gz
$ rm theme.tar.gz

On windows, download http://www.7-zip.org/. This free tool works with several unix specific zipped files. I have installed cygwin, which allows me to run unix command-line tools on my windows machine.

Installing Themes

Once you have extracted the files, you need to upload the folder into the themes folder. I use fireftp to upload files. It is very neat firefox plugin.

Once you have uploaded your files, they should become visible in the list of themes:

Administer > Site building > Themes

Click on the radio button and checkbox to the right of your new theme and click on save configuration.

Deleting Themes

To delete a theme, just delete its folder from the theme.

Modules

Different websites have different needs. The needs of Amazon, Google, and the neighborhood pizza restaurant differ greatly. This is why most no single software can respond to the needs of every client. Drupal was built with this in mind. Drupal comes with a core which can be extended with modules. The core provides essential functions and enables integration and controlled interaction between different modules. Modules can be created by anyone. Modules integrate seamlessly with drupal as long as they are created following drupal guidelines and conventions. Hundreds of really cool drupal modules are available for free on the Internet. Your goal as a beginning drupal user should be to find and install the modules that would allow you to provide the functionality you want to provide to yourself and your users.

Using Drupal Modules

Before a module can be used, it must be enabled.

Administer > Site building > modules

Click on the checkbox next to Contact and then click on Save configuration. Once a module is enabled, its settings and other options become visible. In this case, the Contact form link become visible under Site building. Lets create a contact form.

Administer > Site building > Contact Form > Add Category

Fill in the form and hit submit. Repeat this several times, once for each email account that would be receiving emails. Type the following URL in you address bar:

http://your-website.com/contact

Here you would see a contact form where the category allows you to choose between email accounts. Note that the email addresses are not show and thus cannot be copied by spambots.

Downloading Drupal Modules

Drupal comes with several preinstalled modules such as Contact form we just used. As there are hundreds of modules, most of the modules you would use would have to be downloaded and installed. Modules can be found at http://drupal.org/project/Modules. Suppose we want to download the diff module. Drupal themes and modules are available as zipped tar files. On Unix, you do the following:

$ wget http://the-site/module.tar.gz
$ tar -xzvf module.tar.gz
$ rm module.tar.gz

On windows, download http://www.7-zip.org/. This free tool works with several unix specific zipped files. I have installed cygwin, which allows me to run unix command-line tools on my windows machine.

Installing Drupal Modules

Once you have extracted the files, you need to upload the folder into the modules folder. I use fireftp to upload files. It is very neat firefox plugin.

Once you have uploaded your files, they should become visible in the list of modules:

Administer > Site building > Modules

Click on the radio button and checkbox to the left of your new module and click on save configuration to enable it.

Before installing a module, you should read its README.txt and INSTALL.txt file. Certain modules conflict with others, and some require special configurations. These small and easy to read files would save you lots of trouble.

Deleting Modules

To delete a module, just delete its folder from the modules directory.

Setting attachment size and type

File size

Both PHP and drupal impose limits on the file size of attachments. To edit the default settings:

Administer > Site Configuration > File Uploads

Here you can set the default size for your attachments. At the bottom you would see something like:
Your PHP settings limit the maximum file size per upload to 2 MB.

You cannot define a value greater than this value in your Default maximum file size per upload field. This value is defined by the upload_max_filesize in the php.ini
upload_max_filesize = 2M

You can change this to any positive integer, 50 for example. Remember to backup your php.ini file before you edit it.

File types

For sound security reasons every file type is not allowed in an attachment. The allowed attachments are listed in Default permitted file extensions field on the following page.

Administer > Site Configuration > File Uploads

You can edit Default permitted file extensions field to add or remove file extensions.

Drupal Forms

forms

making your checkboxes preselected in edit forms

Imagine this scenario. You create an add form with checkboxes among other fields. When the user submits, your form stores this information in a database table. Then the user decides to edit his selection. He goes to the edit form. There he sees his previous choices already selected. This modifies his selection and his modifications are registered on a database table.

This simple scenario is quite complicated to implement in drupal. When faced with this problem, I rigorously searched through the drupal documentation and blogs to find the solution. Unfortunately, I couldn't find anything. Then I looked into the existing drupal core modules and imitated their functions. I wrote this page so that others don't have to spend as much time as I did on this problem.

Checkbox data is stored in an associative array. The format of the associative array is Array(id=>name, id2=>name2, ...) by default. The checkboxes are populated by the value of #options attribute. The #default_value attribute defines the default value(s). The default values are unchecked for each checkbox.

Once a form is processed, drupal merges all keys and values. To make an editable format, we would be exploiting this property. We will pass Array(id=>value,...) to #options and nothing to #default_value. In the edit form, we would pass Array(name=>name) to #options and Array(id=>name) to #default_value. When the form array is merged, all values with id=>name will replace their corresponding name=>name pairs.

Thus we end up with a list of all option displayed and chosen ones checked.

/**
 * Implementation of hook_form().
 */ 
function projects_form(&$node) {
  // project title
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Project Title'),
    '#required' => TRUE,
    '#default_value' => $node->title,
    '#weight' => -5
  );

  // project description
  $form['body_filter']['body'] = array(
    '#type' => 'textarea', 
    '#title' => t('Project Description'), 
    '#default_value' => $node->body, 
    '#rows' => 15, 
    '#required' => TRUE
  );
  $form['body_filter']['format'] = filter_form();

  // users sharing the project
  if (arg(1) == 'add') { 
    // returns Array(id=>name,id2=>name2 ...)
    $checklist = addformlist(); 
  } else { 
    // returns Array(name=>name,name2=>name2 ...)
    $checklist = editformlist(); 
    // returns Array(id=>name,id2=>name2 ...)
    $shred = previouslyselected($node->nid);
  }

  // my checkboxes
  $form['sharers'] = array(
    '#type' => 'checkboxes', 
    '#title' => t('Share with'), 
    '#default_value' => $shred, 
    '#options' => $checklist, 
    '#description' => t('some description.'), 
    '#required' => FALSE
  );

  return $form;
}

addformlist() return the options in Array(id=>name) format. editformlist() return a options in Array(name=>name) format. previouslyselected() returns a list of previously selected checkboxes in Array(id=>name) format. The important variables are the $checklist and $shred arrays. If you understand the format they expect and how to apply them, then that's all there is to it.

Modifying your forms in drupal

Drupal forms can be modified by the form alter hook. This performs alterations to your form before it is rendered. It is especially useful when you are writing a module which modifies another module. For example, a mypage.module could modify the page module by removing the comment and author fieldset along with the log message textarea and adding two new textfields.

First time users of hook_form_alter often get frustrated since their modifications work on certain fields and not others. This is due to the fact that drupal loads modules in alphabetical order and overriding modules, such as mypage.module mentioned above, must be loaded after the modules they override. There are two ways to solve this problem. You can change name of your module such that is loaded after the module you wish to override. A better way would be to go into the system table is the database and modify the weight of the module. All modules are assigned the weight zero by default. Therefore, modifying the weight of your module form 0 to 1 would assure that your module would be loaded in the desired order.

Modifying a form is a form step process:

Step 1: Define a _form_alter form

function mypage_form_alter($form_id, &$form) {

  return $form
}

The function name must end with _form_alter. The function takes $form_id and a reference to the $form array as parameters. This function returns the $form array reference after modifications.

Step 2: Define a _form_alter form

function mypage_form_alter($form_id, &$form) {
  if($form_id == 'mymodule_node_form') {

  }
  return $form
}

It is prudent to test for your form_id. This would serve to eliminate a number of difficult to debug errors. If you do not the name of your form, view the form source in the browser. It should look something like:

<input type="hidden" name="edit[form_id]" id="edit-mypage-node-form" value="mypage_node_form" />

Thus the form_id is mymodule_node_form.

Step 3: Modify or unset undesirable fields

function mypage_form_alter($form_id, &$form) {
  if($form_id == 'mymodule_node_form') {
    // modify attributes of existing fields
    $form['author'] = array('#type' => 'hidden');
    $form['options'] = array('#type' => 'hidden');

    // remove form fields
    unset($form['menu']);
    unset($form['path']);
  }
  return $form
}

In this example, I set two fieldsets to hidden. This has the same effect as removing a field from the user's point of view. However, the difference is significant from a module developer's point of view. Hidden fields allow a developer to pass defined values. unset() simply removes the form elements from the $form array.

Step 4: Adding new fields

function mypage_form(&$node) {
  $form['field1'] = array(
    '#type' => 'textfield', 
    '#title' => t('field1'), 
    '#required' => TRUE, 
    '#default_value' => $node->field1, 
    '#weight' => -5
  );
  $form['field2'] = array(
    '#type' => 'field2', 
    '#title' => t('field2'), 
    '#default_value' => $node->field2,
    '#required' => TRUE
  );
}

As you can see, adding fields to a form simply involves adding fields as you would add to a any drupal form. You just have to make sure that you add your field to the right form array. Page module uses node module forms. Therefore, we add to the $node array.

Beware

Node form fields post data in database tables. When you unset a field, a default value is posted in its place. For example, if you unset author, the uid field in node table would get a 0 value by default.

Making a text field uneditable

Every now and then, we need to show the data in a form field, pre-checked checkboxes, or pre-selected selection menus, which should not be editable by the user. Very often, these sort of functions are used in permissions and access control related pages.

In HTML, an uneditable form field can be created as follows:

<input type="text" readonly="readonly" name="cantedit" />

In drupal, an editable form field can be created as follows:

$form['name'] = array( '#type' => 'textfield', '#title' => t('name'), '#attributes' => array('disabled' => 'disabled'), );

Drupal Secondary Menus

Creating secondary menus is not very straightforward in drupal. Following are the instructions:

1. Administer > menus
2. Create a menu called "Secondary Links"
3. Add items to the menu
4. Administer > settings > menus
5. Choose secondary links for "Menu containing secondary links"

That's all.

To change the position of secondary menus, you can modify page.tpl.php.

Using Drupal

Most people agree that drupal is very powerful but it is not very user-friendly. I agree that drupal is powerful. I would, however, like to add that drupal is not user-friendly for beginners. Drupal is user-friendly but it has a steep learning curve. My goal in this section is to guide beginners through drupal.

hook_insert, hook_update, and hook_delete are called first

We creating a node module, database operations for insert, update, and delete are handled by the node module. You don't have to do anything. However, coding for the database operations of your custom fields is your problem. To insert, you implement hook_insert(). hook_update() for updates and hook_delete() to delete row(s).

It is common to use the results of one query as input for another. For example, you created a node and you need to store the generated node id in another table. Unfortunately, this operation cannot be performed in the insert, update, and delete hooks since node's own database operations are performed after the hooks have done their work.

Clear cache

Drupal code is very heavy on SQL Usage. It is not uncommon to run 5 or more SQL queries just to display a page. As you can imagine, this slows down the website significantly. In addition, this increases load on the server. To go around this problem, drupal offers the possibility to cache the pages the user has already visited. This way, there is only one database call, one simply SQL query to run, reduced load on the server, and run better response time.

New drupal developers often get frustrated by drupal's caching mechanism. You make a change but you don't see the change since the menu is coming from the cache. You think the problem is in the code, and you try to find the culpable code in vain. To avoid this agonizing situation, you need to do the following two things:

  1. disable page caching
  2. Install the clear cache module

Disabling page caching

  1. Go to Administer >> Settings
  2. Click on Cache Settings
  3. Under the Page Cache heading, select Disabled
  4. Hit Save Configurations

Installing the clear cache module

Following is a small module I created which cleans your cache and rebuilds the menus. Copy paste this code to create a clear_cache.module under the modules directory. Then go to Administer >> modules to enable this module. All you need to do to flush your cache is to click on the Flush cache link inside the navigation menu.

<?php

function clear_cache_help($section) 
{
  switch ($section) {
    case 'admin/modules#description':
      return t('cleans cache');
  }
}

function flushcache_menu($may_cache) 
{
  $items = array();

  if ($may_cache) {
    $items[] = array( 'path' => 'admin/clear_cache', 
                      'title' => t('Clear cache'),
                      'callback' => 'clear_cache_page',
                      'access' => user_access('administer email aliases')); // or something else
  }
  return $items;
}

function clear_cache_page(){
  menu_rebuild();
  db_query("DELETE FROM {cache}");
  drupal_set_title('Flush Cache');
  drupal_set_message('Cache has been flushed');
  print theme('page', '');
}
?>

To clear you cache and to rebuild your menus, simply click on Administer >> clean cache.

Drupal Paging

Drupal has very powerful paging capabilities. This document explains it usage and capabilities using examples. Lets start by creating a module called paggar. If you are wondering why I used such strange sounding name for the modules, her goes a simple explanation. pager module already exists and pagger is not a very polite word.

paggar.info

name = paggar
description = paging example
package = mole
core = 6.x
version = 6.3
project = mole

paggar.module

// paggar.module - molecularsciences.org

// help
function paggar_help($section) 
{
  switch ($section) {
    case 'admin/modules#description':
      return t('Paging Example');
  }
}

// permissions
function paggar_perm()
{
	return array('enable paggar');
}

function paggar_menu()
{
	$items['paggar'] = array(
		'title' => 'Paging example',
		'page callback' => 'paggar_example',
		'access callback' => 'user_access',
		'access arguments' => array('enable paggar'),
		'type' => MENU_CALLBACK
	);
	return $items;
}

// paging example
function paggar_example()
{
	// title for the page
	drupal_set_title("Paging example");

        // query
	$q = "select distinct title from {node} where type like 'page'";

	$rs = db_query($q);
	$o = '<ul>';
	while($rw = db_fetch_object($rs))
	{
		$o .= '<li>' . $rw->title . '</li>';
	}
	$o .= '</ul>';
	
        return $o;
}

This module would print the titles of all page nodes. No paging yet. To add paging, we need to provide the following:

// paging example
function paggar_example()
{
	// title for the page
	drupal_set_title("Paging example");

	// how many nodes per page
	$nodes_per_page = 20; 

        // query
	$q = "select distinct title from {node} where type like 'page'";

	// count query
	$cq = "select count(distinct title) from {node} where type like 'page'";

	$rs = pager_query($q,$nodes_per_page,0,$cq);

	$o = '<ul>';
	while($rw = db_fetch_object($rs))
	{
		$o .= '<li>' . $rw->title . '</li>';
	}
	$o .= '</ul>';

        // print paging links
	$o .= theme('pager', NULL, 10);

	return $o;
}

You must pass the query, an integer specifying the number of entries to display per page, paging identifier, and the count query to the pager_query

How to turn off drupal messages

A red error message displaying on your webpage, visible to every visitor is the worst thing you can do to your site. Unfortunately, drupal displays error messages on the screen by default. There are several solutions to this problem.

1. Install disable_messages plugin
The disable messages plugin is only available for drupal 6 and drupal 7.

2. Edit page.tpl file
Remove the following piece of code from your page.tpl file

if ($show_messages && $messages): print $messages; endif;

3. Edit style.css file
Go into your style.css file and find the block for error messages. Then add the following line to it.

display: none

4. Edit error reporting preferences
Go to Administer > Site Configuration > Error Reporting
Set
Write error messages to the log and to the screen
to
Write error messages to the log

Linking in drupal

Links can be quite confusing in drupal. When I started writing drupal modules, I quickly came across problems with links. The purpose of this page is help new drupal module builders to spend less time figuring links out than most of us. In drupal links are created with url() and l() functions. It is however recommended that you use l() instead of url().

Syntax

l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE)

Parameters

$text
The text to be enclosed with the anchor tag. The link which is hyperlinked. In case of an image, you would place an <img> tag here.

$path
The link url. You can either use the entire http://www.mysite.com/node/publications address or start from you drupal installation directory. In the latter case, node/publications. If you are using aliases, don't use the full address method.

$attributes
An associative array of HTML attributes to apply to the anchor tag. In simpler words, an array of attributes such as target="_blank", etc.

$query
A query string to append to the link. All the stuff which follows the ? in a url.

$fragment
Place you anchor here starting with the # sign.

$absolute
If you absolute need an absolute address, set this to TRUE.

$html
If you link is not a text i.e it is an image, set this to true.

Some examples

When it comes to programming, nothing make life easier than a sample of code.

Linking Text

l('mylink', 'url_of_the_link');

Opening link in new page

l('mylink', 'url_of_the_link', array('target' => '_blank'));

Linking Image

l("<img src='my_image'>", 'url_of_the_link', NULL, NULL, NULL, FALSE, TRUE);

Adding query string

l('mylink', 'url_of_the_link', NULL, '?id=56', NULL, FALSE, TRUE);

Internal anchors

l('mylink', 'url_of_the_link', NULL, NULL, '#section8', FALSE, TRUE);

nodeapi explained

Nodeapi is a very useful hook which allows modules to react to actions affecting all kinds of nodes regardless of the module defining the node. Like most things in drupal, nodeapi is very powerful but difficult to understand. Here I present some examples to reduce the learning curve.

For our examples we would work on a custom node type called "theory".

Administer > Content Management > Content types > Add Content Type

Type "theory" in the first two fields, fill out the remainder of the form as you wish and click on "Save content type". A "theory" menu should appear under the Create content menu. Click on it and create a node of type theory.

Display a line of text with nodeapi

Inside the modules directory create a directory called "nodi". Create a nodi.info file, paste the following text and save it.

name = nodi
description = nodi
package = Core - optional
core = 6.x
version = "6.3"
project = "nodi"

Create a nodi.module file, paste the following text and save it.

function nodi_perm() { 
  return array('use nodi'); 
} 

function nodi_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    // when in view mode as opposed to edit, delete, etc.
    case 'view':
      // if the node type is theory. we don't want to modify all nodes.
      if($node->type == 'theory') {
        // append the following text to the body
        $node->content['body']['#value'] .= 'body added by nodi module using nodeapi!';
      }
      break;
  }
}

Enable the nodi module and set permissions.

Administer > Site Building > Modules
Administer > User Management > Permissions

Now go to view the theory node you created in the beginning. You should see "body added by nodi module using nodeapi!" at the end of body text.

Using nodeapi when deleting a node

function nodi_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL)
{
  switch ($op) {
    case 'delete':
      if($node->type == 'theory') {
        drupal_set_message('You just deleted theory node.');
      }
    break;
  }
}

This would display a message when a node is deleted.

Other options include insert, load, prepare, print, presave, update and validate.

Using drupal6 actions

In drupal 6, actions and triggers have been added to the core. But what are actions used for? Lets say, you wish to receive an email every time someone leaves a comment. This can be accomplished with actions in less than 60 seconds. Here's how:

  1. Go to Administer > Site configuration > Actions
  2. Scroll down to "Make a new advanced action available" and choose "Send email..."
  3. Type your email, a subject, a message and hit save
  4. Click on the create button
  5. Go to Administer > Site Building > Modules
  6. Enable Trigger module
  7. Go to Administer > Site Building > Trigger
  8. Click on the Comments Tab
  9. In the "Trigger: After saving a new comment" section choose the "Send email..." action we just created
  10. Click on the Assign button

That's all. Make sure that you have given the necessary permissions for posting comments to your users and test it by adding a comment.

Using Multiple Themes

outline for the article:

download taxonomy_theme http://drupal.org/project/taxonomy_theme
Administer > Site building > Modules
check the checkbox next to taxonomy theme
Save configuration

Administer > Site configuration > Taxonomy theme
Check Enable Taxonomy-based templates
Check Show theme option on term/vocab/content-types pages
Save

Taxonomy
term_based save

Administer > Categories
Vocabulary: Theme switch
Description: Permits switching of themes
Help text: type name of an active theme
check Page
check Disabled
Uncheck rest
weight: 0
submit

add terms
- sky
- garland
- ad agency
- bluemarine
- chameleon
- imagination
- marvin
- push button

Administer > Site configuration > Taxonomy theme > Taxonomy
Category to use for template selection: Term switch

Removing breadcrumbs

Seasoned web developers tend to assume that everyone would want to have breadcrumbs. However, there are many situations where the site owner would not like to have breadcrumbs, either due to design constraints or the size of the website. Why would you place breadcrumbs on a 12 page website where each page is linked to every other page on the website?

Breadcrumbs refers to the Home >> Admin >> Menus >> ... links at the top which allow the user to trace back to home. This is a term inspired by the famous story of Hansel & Gretel, where Hansel leaves a trail of breadcrumbs to help them find their way back home.

There are two easy ways to remove breadcrumbs from the website in drupal. You can either edit the css file or the template or theme file.

If you are using a PHPTemplate based theme, you should have a page.tpl.php somewhere inside the themes directory. You should comment out the following code:

// if ($breadcrumb) print $breadcrumb; 

Instead if you are using a theme such as chameleon or marvin, you would not find a page.tpl.php. You should open the .theme file and comment out the following line of code

//$output .= theme("breadcrumb", drupal_get_breadcrumb());

If you prefer not to edit these files, you can add the following code to your css file:

.breadcrumb {display: none;}

Fatal error: Allowed memory size exhausted

Drupal can be very memory intensive CMS, especially if you have lots of menus, blocks and modules. If you exhaust the allowed memory size, you would get an error such as the following

Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 41 bytes) in somefile.ince

To fix this problem, you need to allocate more memory.

1. Open you php.ini file
If you don't know where this file is, run locate php.ini. Mine is located at /etc/php.ini. Make sure you back up this file before editing it.

1. Open you php.ini file
If you don't know where this file is, run locate php.ini. Mine is located at /etc/php.ini. Make sure you back up this file before editing it.

2. set memory_limit to 32M
Find memory_limit and modify 16M to 32M. You can choose more if you think you would need more memory.

3. restart apache
/sbin/service httpd restart

4. insert a line in settings.php
Edit sites/default/settings.php inside your drupal directory. Insert the following line.

ini_set('memory_limit', '32M');

If this doesn't work try using 64M or more. If you program is taking too much memory, you should check to see if it is coded properly.

Drupal Links

- Drupal Modules
- Drupal Themes
- Fantastic article on input formats and
filters

- Captcha Video Tutorial