[development] Getting absolute directory path

Darren Oh darrenoh at sidepotsinternational.com
Wed Mar 14 13:53:53 UTC 2007

Some users keep contributed modules outside the Drupal directory and  
create symlinks to them in sites/all/modules. This causes problems  
for Chat Room, which uses a PHP file in its own directory for AJAX  
updates (to avoid loading all of Drupal on each update) but must  
include some files from Drupal. I was using the following code to  
find the Drupal files:

     $chatroom_base = urldecode($_POST['chatroom_base']);
     $depth = substr_count($chatroom_base, '/');
     chdir(str_repeat('../', $depth+1));

If people are keeping Chat Room outside of Drupal, chdir() will need  
the absolute path to the Drupal directory. What is the best way to  
get this?

More information about the development mailing list