Using Drupal API in your website

(If you're looking for a way to bootstrap your automated/scheduled scripts, then look here. This guide is for bootstrapping Drupal to pages loaded by your browser.)

As this is written for Drupal 6.8, instructions may vary for other versions (5.x, 7.x, etc).

Download Drupal and extract files into /path/to/website/drupal

1. Installation
Install Drupal by visiting http://domain/drupal/install.php in your browser.
Ensure no table name conflicts with existing site (ie. any tables named "users", "files" or "access")

2. Bootstrapping the Drupal API
[ source ]
This allows full access to Drupal API from without your website.

The following code is a modified version of ceejayoz's script bootstrap code.

* Allows us access into Drupal's API.
function initialise_drupal_bootstrap() {
// Determine Drupal's directory
$DRUPALINC = realpath('./drupal');

// Adjust PHP's include path so Drupal properly includes it's dependencies
$paths = explode(';', get_include_path());
$paths[] = realpath('./');
$paths[] = $DRUPALINC;
set_include_path(implode(';', $paths));

// Save current working directory
$cwd = getcwd();

// Call Drupal's bootstrapping code

// restore error reporting to its normal setting

Whenever you need to enable the Drupal API on a page, simply call initialise_drupal_bootstrap().

3. Edit .htaccess
This step is optional for Linux users, as you can simply create a symlink to the paths required.

Copy "/path/to/website/drupal/.htaccess" to "/path/to/website/" and open it up in a text editor.
Uncomment the line with "RewriteBase" and set it to "RewriteBase /drupal"

4. Test
  • Open your main page, it should show your original site. (ie.
  • Attempt to access a Drupal rendered page, such as your user profile page at ""
  • View the Drupal main page, at ""

5. Configure
Log in as the administrator and view the page "" to set up your default front page.
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog