Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By InfluenceJamie on
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
If other calls work I would
If other calls work I would guess a typo, possible a invisible character. I would try typing it
No luck
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?
What is the context of the
What is the context of the code?
It's being used to add a
It's being used to add a script in the page.tpl.php file. See my code above in the original post.
Extra /
Possibly an extra '/'? What about trying
I had problems with drupal
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.