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

查看:20
本文介绍了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天全站免登陆