Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save About2git/5951432 to your computer and use it in GitHub Desktop.
Save About2git/5951432 to your computer and use it in GitHub Desktop.
Drupal: add JS (Javascript) only on Frontpage via template.php function hook
function YOURTHEMENAME_preprocess_page(&$vars, $hook)
{
// jQuery - diese Scripte fuer alle Seiten einbinden
drupal_add_js(drupal_get_path('theme', 'YOURTHEMENAME') . '/js/sidewide.js', array('scope' => 'footer', 'weight' => 80));
// jQuery - diese Scripte nur auf Startseite einbinden
if ($vars['is_front']) {
drupal_add_js(drupal_get_path('theme', 'YOURTHEMENAME') . '/js/plugin.js');
drupal_add_js(drupal_get_path('theme', 'YOURTHEMENAME') . '/js/script.js', array('scope' => 'footer', 'weight' => 99));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment