Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By bkelly9376 on
Is is possible to use drupal_add_js with more that one get parameter in the source url? When I try this the ampersand gets urlencoded. For example, the google maps api:
drupal_add_js('http://maps.googleapis.com/maps/api/js?v=3.7&sensor=true');
results in:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.7&sensor=true"></script>
Comments
May you could try to escape
May you could try to escape it like this :
Thanks for the reply. I've
Thanks for the reply. I've tried escaping and it doesn't make a difference.
Have a look also in
Have a look also in drupal_add_html_head .
Your code doesn't work at
Your code doesn't work at all? Because I tested it in my computer and the map shows up fine..
I tried the following code
I tried the following code but it didn't work:
try this with a module init
try this with a module init function
Does it exists another
Does it exists another solution ?
You can try this, but I
You can try this, but I haven't tested to see if it stops encoding the ampersand or not:
No, that previously untested
No, that previously untested code doesn't work.
What was your final solution?
What was your final solution? I ended up modifying html.tpl.php, which I don't feel is the best way to do it. But this html/php code got me up and running at least:
I used drupal_add_html_head()
I used drupal_add_html_head() for this.
drupal_add_html_head to add an external script with GET vars
Ran into this post while trying to add google maps with a key just now. Here is what worked for me:
In a theme preprocess function (I used MYTHEME_preprocess_page, as it suited my purposes well) I added the following code:
I had to use an element of type markup to get the closing script tag in place, otherwise it output as
<script src="..." />
instead of<script src="..."></script>
which broke pretty much everything.Module solution
ok so i was caught in this trap too ... and tried a lot of stuff
so what I did in the end was :
in template.php
in module
so every time we change stuff now in our require.js we just need to run flush cache and yes bob is my uncial
In main.js