Add a js to a specific page from a module in Drupal
function mymodule_preprocess_page(&$variables) { | |
if (isset($variables['node']) && $variables['node']->type == 'book') { | |
// Add js | |
drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.awesome.js'); | |
$variables['scripts'] = drupal_get_js(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment