Hi guys,
I use the location module in one of my websites to collect a series of addresses.
Using those addresses, I construct a google map and drop pins on it for each one of the locations in the database.
I use ajax to manually accomplish the reading of the locations from the database, and then I pass that information into javascript which drops each pin on the map according to the longitude and latitude.
The problem is I can't get past the first line of code which is simply getting the "Current Working Directory".
$current_dir = getcwd();
#print "<br> Working in directory : {$current_dir}";It all worked fine on the local host. When I print $current_dir, I get the current location which then feeds into the rest of the code and retieves all my venues. The current directory is simply the base of the theme currently in use.
When I put the site live, I got extra values appended to the front of the CWD which I is throwing everything off and my ajax is coming back with a "file not found" error.
The output looks like :
Working in directory : /var/www/vhosts/my-site.com/httpdocs/sites/all/themes/garlandI don't need the ugly /var/www/vhosts/ upfront but I don't know how to deal with that. Can you help ?
Alternatively, if someone can suggest a different and better ajax approach, I'd be very grateful ;-)
Comments
One of these should help
Try the drupal_get_path function or $theme_path global var for the current theme.
One little problem
Thanks for those suggestions. I'm certain they would work except for one small detail.
I created a php script call template_ajax.php and it contains my ajax response code. My guess is when I tried
global $theme_path; print $theme_path;, $theme_path wasn't recognised because it is outside of the drupal collective - just my guess, Icould be wrong.Neither did drupal_get_path work.
When the ajax code worked on my localhost, I used
require_once './includes/bootstrap.inc';to tap into drupal but in this case, without getting the current working directory sorted, the require_once code won't work.I hope I've made sense here.........I could really use your help.
hmmmm
Is there any particular reason you've chosen to put this into a standalone script rather than a Drupal module?
Yes.........
the simple truth is I'm struggling to put together a functioning drupal module.
I only just put a message up asking for help a module's development.
How would a module help me with this ajax issue however ?
..
For me, the main advantage is that it can interact with everything else in Drupal. Obviously this can be achieved by bootstrapping, but making a module of it means that the rest of Drupal "knows" about it, sort of thing.
Just reading your Module Development thread, I'll try to throw a reply over there to keep things tidy.