开发者

Drupal where to set global variables accessible to all pages on the site?

Im working on a Drupal installation where the 开发者_StackOverflowsetup in my local testing server is different from online server.

On my local server drupal is installed in /var/www/my_drupal and the base_path is set to /mydrupal but on the online server its installed on the root of the site, usually /public_html/

So my problem is I wanted to set a base_path and base_url variable depending on the server i am on. Where do i place my codes so that it's accessible site-wide.?

Thanks!


Luckily Drupal already has taken care of this for you

See the api site for a full listing

Of particular interest to you should be:

$base_path developer/globals.php The base path of the drupal installation. At least will default to /.
$base_url developer/globals.php The base URL of the drupal installation.


I would set it in your settings file in sites/default/settings.php just use an if statement to detect whether it is the local or live site ur on and then set the variables accordingly.

if ($_SERVER['SERVER_NAME'] == 'localhost') { // the script is running on the local } else { // it is on remote }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜