For some reason the drupal_get_path() is not working?!? I'm trying to run the following code:

 if (strstr($_SERVER['REQUEST_URI'], "contact")) {
	drupal_add_js(drupal_get_path('theme', 'weinfluence') . '/js/infmap.js');
	}

Which should produce <script src="http://myurl/sites/all/path-to-my-theme/js/infmap.js"></script> but instead all I get is <script src="/js/infmap"> essentially ignoring the drupal_get_path function.
Its a piece of code I run quite often in my themes, so I don't know why it suddenly wouldn't be working.

Any ideas would be greatly appreciated.

Comments

nevets’s picture

If other calls work I would guess a typo, possible a invisible character. I would try typing it

InfluenceJamie’s picture

I've tried retyping it out and tried taking it out of the if statement, I've even tried copying and pasting the code out of other theme files that I've written in the past, it's still not working for some reason... It's as if drupal doesn't recognize the command anymore. Does anyone know what part of drupal common commands are initially created in?

nevets’s picture

What is the context of the code?

InfluenceJamie’s picture

It's being used to add a script in the page.tpl.php file. See my code above in the original post.

jonawebb’s picture

Possibly an extra '/'? What about trying

    drupal_add_js(drupal_get_path('theme', 'weinfluence') . 'js/infmap.js');
Bertjuh’s picture

I had problems with drupal_get_path and ended up here via Google. Thought to leave the solution for my problem. We are migrating from Windows servers to Linux servers and Linux is case sensitive. So finding a file that's called myfile.inc as MYfile.inc works on Windows, but NOT on Linux.