Drupal:如何使用独立的PHP脚本访问Drupal的API? [英] Drupal: how to access to Drupal's APIs with a standalone php script?

查看:157
本文介绍了Drupal:如何使用独立的PHP脚本访问Drupal的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在单独的php文件中创建一个新的脚本以运行Drupal,我需要添加以下行以访问所有Drupal API:

When I create a new script in a separate php file to run for Drupal, I need to add the following lines on top in order to access all Drupal APIs:

require_once'./includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

这是否正确?

推荐答案

是这样的:

/** bootstrap drupal **/
chdir("/path/to/drupal/site/htdocs");
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

然后只需添加下面需要的任何Drupal特定的代码。

And then just add whatever Drupal-specific code you need below that.

这篇关于Drupal:如何使用独立的PHP脚本访问Drupal的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆