First let me say, I did a search of everything here on this site, but could not find the specifics on what I need.

1- I want to use some java scripts for just one page so when any of the other pages load it does not have to run through that code.

2- I want the same page template as the rest of the site, so no need to change anything.

3- A page that looks the same as the rest of the site but has the java code that I want for the one page that uses it.

I used custom_node_template module but it does not do what I am looking for.

Any suggestions....

Gene

Comments

kbalderson’s picture

I'm assuming that by "page" you mean a node, of type "page", that you want to create.

If this is the case, you can enable the "php" module to enable the php input filter.

You can then add your javascript file using drupal_add_js().

Otherwise, you can open your theme's page.tpl.php file, and use a simple if statement to add the script.


if (arg(0) == 'somepath') {
  print '<script type="text/javascript src="some/javascript/file.js"></script>';
}

breeze76’s picture

Would this add the script for that one page or all of the pages on the site? I just need it for one page..

kbalderson’s picture

As long as the page is a node, the first method will add it only for that page.

The second method, where you would go into the theme, would do the same, but you have to modify the page.tpl.php of your theme. Use this method if your page is just a page, and not a node.

kbalderson’s picture

if ($_GET['q'] == 'path/to/page') { // use this if your pages path is more than 1 level deep.
  print '<script type="text/javascript src="some/javascript/file.js"></script>';
}