I haven't developed any modules for Drupal before and I guess really i'm just wanting some verification as to if this is "right" and I hope someone can help. Its been developed for Drupal 7, and is used to inject a javascript file into the footer of the page
sessioncam.module file:
<?php
/**
* @file
* The code below adds the sessioncam.js file in the footer section of your site
*/
?>
<?php
drupal_add_js(drupal_get_path('module', 'sessioncam') .'/sessioncam.js', array('type' => 'external', 'scope' => 'footer')) ;
?>
sessioncam.info file:
name = SessionCam
description = Module to inject the SessionCam recorder code
core = 7.x
Any help is appreciated
That's not quite right. The call to drupal_add_js() shouldn't be in the global scope but in a hook function. If you want it added on every page hook_init() would be appropriate:
function sessioncam_init() {
drupal_add_js(drupal_get_path('module', 'sessioncam') .'/sessioncam.js', array('type' => 'external', 'scope' => 'footer')) ;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With