Created
July 30, 2020 13:57
-
-
Save ndvo/feaf1a6b398e02203e2f998c3389bfb9 to your computer and use it in GitHub Desktop.
Add a js to a specific page from a module in Drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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