How can I call a Drupal function or get the global variable in a PHP file which is located under the drupal installation folder. I doing it for the first time. Are there any files I need to include in my code in order to access the Drupal function or variables?
10
votes
Possible duplicate: stackoverflow.com/questions/5014244/…
- Laxman13
I strongly recmmend that you consider writing a module instead of adding arbitrary PHP files for things that should be part of the website. And for scripts, you can write drush scripts (drupal.org/project/drush).
- Berdir
@Berdir I am using it for testing purpose.
- Dijo David
4 Answers
7
votes
Taken from the linked question in the comment above
You need to Bootstrap Drupal in the external PHP file:
/** bootstrap Drupal **/
chdir("/path/to/drupal/site/htdocs");
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Be sure to change the path to your Drupal installation, then add your code below the code posted above.
10
votes
2
votes