How to Connect to Drupal From an External PHP
Drupal is a free, open-source content management system solution that allows website owners and developers to create and edit dynamic websites from an online dashboard. The software is written in the PHP programming language and relies on a database to store the data of the system. All PHP files within the Drupal installation are automatically configured to communicate with the database. The Drupal bootstrap command allows you to connect PHP files that reside outside of the Drupal installation.
Instructions
-
-
1
Click “Start,” then “All Programs” and select “Notepad.”
-
2
Click “File” and select “Open.” Select the PHP file and click “Open.”
-
-
3
Copy and paste the following code at the bottom of the PHP file:
//set the working directory to your Drupal root
chdir('/home/public_html/drupal/');//require the bootstrap include
require_once './includes/bootstrap.inc';//Load Drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
//(loads everything, but doesn't render anything)//display a node
print '<pre>';
print_r(node_load(12));
print '</pre>'; -
4
Click “File” and select “Save.”
-
5
Upload the saved PHP file to your Web server.
-
1