Hi,
I'm using Drupal 6.4 with a variety of modules to port my own home-grown site to Drupal. So far, things work nicely.
What I'm looking for now is a way to add javascripts to specific pages. These scripts don't do much more than take the values entered on the page and perform some calculations.
So far the only method I found was adding a line to the template linking in my own javascript file.
What I don't like about this method is:
1. I need to modify the template, which needs to be repeated every time the template is updated.
2. I need to modify the template for a non-template related issue.
3. the javascript file is loaded for EVERY page, not just the relevant ones.
Is there another way to make this work?
Thanks.
Comments
this worked for me on some
this worked for me on some things...especially when calling jquery related scripts
http://api.drupal.org/api/function/drupal_add_js/5
This sounds like a good
This sounds like a good idea, but where do I add the line of code? To the page, to the theme? I can't figure that out from the description.
Thanks.
=-=
on a specific page you would want to use inline, I believe:
Searching on drupal_add_js
Searching on drupal_add_js gives the impression that it's added to the template. Which brings me back to my earlier disadvantages.
=-=
custom tpl.php pages should allow you to do what you're after and won't be overwritten when the theme is updated as any tpl.php files you create won't be part of the package.
- Create a new region, like
- Create a new region, like region['js'] = Javascripts
- Place the region in page.tpl.php or any other .tpl.php page file within the .
- Add a block and place a page specfic javascript in it.
- Drag the block to the javascripts region and set it to only show on the page you want to use the javascript.
Probably not the best way but sure a good and working / simple way.