Skip to content

Instantly share code, notes, and snippets.

@kidsil
Created June 18, 2010 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidsil/443992 to your computer and use it in GitHub Desktop.
Save kidsil/443992 to your computer and use it in GitHub Desktop.
//Add this at the start of preprocess_page to add a JS when you ADD or EDIT a certain content type.
if (arg(0) == 'node' && ((arg(1) == 'add' && arg(2) == 'contenttype') || ($vars['node']->type == 'contenttype' && arg(2) == 'edit'))) {
// Add your js file as usual
drupal_add_js('YOURJAVASCRIPT', 'theme');
$vars['scripts'] = drupal_get_js();
// Ensure that the addition has any effect by repopulating the scripts variable
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment