In the module I am developing I need to add script which require jQuery.The will be added depending on configuration settings. Hence I am using template_preprocess_module(&$variables)
where I am trying to add script by doing something like this:
function template_preprocess_module(&$variables) {
if (TRUE) {
$variables['jquery'] = ?;
$variables['script'] = 'path to script in module';
}
}
Then in the template I will simply be rendering these variable in the head section. But I am facing trouble in adding jQuery, because I don't know its source (obviously I know its source in core but I need something over here which automates path). Can the source be known by using something like drupal_get_path()
? I am also not sure if this is the best way to add script conditionally, any suggestion regarding this? Thanks.