Skip to content

Instantly share code, notes, and snippets.

@robdecker
Last active November 2, 2019 02:11
Show Gist options
  • Save robdecker/5561527 to your computer and use it in GitHub Desktop.
Save robdecker/5561527 to your computer and use it in GitHub Desktop.
[Put the path to the theme in Drupal.settings for use in javascript files] #d7
<?php
function mytheme_preprocess_page(&$vars) {
// Add the path to this theme to Drupal.settings
$setting['pathToTheme'] = path_to_theme();
drupal_add_js($setting, 'setting');
}
// OR:
function mytheme_preprocess_page(&$vars) {
// Add the path to this theme to Drupal.settings
drupal_add_js('jQuery.extend(Drupal.settings, { "pathToTheme": "' . path_to_theme() . '" });', 'inline');
}
yepnope({
test: Modernizr.touch,
yep: '/' + Drupal.settings.pathToTheme + '/js/hammer.js'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment