Dij*_*vid 10 php drupal external global-variables drupal-6
如何调用Drupal函数或在位于drupal安装文件夹下的PHP文件中获取全局变量.我是第一次这样做.我需要在代码中包含任何文件才能访问Drupal函数或变量吗?
Ale*_*xey 10
如果上面解释的例子不起作用,试试这个:
$path = $_SERVER['DOCUMENT_ROOT'];
chdir($path."/drupal");
define('DRUPAL_ROOT', getcwd()); //the most important line
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Run Code Online (Sandbox Code Playgroud)
摘自上述评论中的链接问题
您需要在外部PHP文件中引导Drupal:
/** bootstrap Drupal **/
chdir("/path/to/drupal/site/htdocs");
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Run Code Online (Sandbox Code Playgroud)
请务必更改Drupal安装的路径,然后在上面发布的代码下面添加代码.