In drupal 7 i am trying to add Custom javascript to .info file of mytheme[Bootstrap business]. I followed the below steps to add js file but it doesn't work.So any body help me how to add custom javascript to an Bootstrap business theme[drupal 7]
/**********************/
With drupal_add_js
If you are adding your .js file from within a theme, then you simply need to make the call from within template.php, you need to add the second parameter this time as 'theme' so that Drupal knows this script should be loaded after all core and module scripts are loaded:
drupal_add_js(drupal_get_path('theme', 'mytheme') .'/mytheme.js');
Using the theme's .info file (Drupal 6 & 7)
You can add your script path in the .info file of your theme and Drupal will include them automatically.
name = My theme
description = Theme developed by me.
core = 7.x
engine = phptemplate
scripts[] = mytheme.js
Using a preprocess_page function
To conditionally add js to the theme, you can use a process_page function:
function mytheme_preprocess_page(&$vars, $hook) {
if (true) {
drupal_add_js(drupal_get_path('theme', 'mytheme') . '/mytheme.js');
$vars['scripts'] = drupal_get_js(); // necessary in D7?
}
}
/**************************/
Comments
Comment #1
dddave commentedI have granted you the role of "not a spammer" so that you can easily post your question in the appropriate forum. https://drupal.org/forum
Also make sure to read https://drupal.org/node/317 for future usage of the issue queue.