我以前没有为Drupal开发任何模块,我想我真的只想要一些验证,如果这是"正确的",我希望有人可以提供帮助.它是为Drupal 7开发的,用于将javascript文件注入页面的页脚
sessioncam.module文件:
<?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')) ;
?>
Run Code Online (Sandbox Code Playgroud)
sessioncam.info文件:
name = SessionCam
description = Module to inject the SessionCam recorder code
core = 7.x
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏
那不太对劲.调用drupal_add_js()
不应该在全局范围内,而应该在钩子函数中.如果你想在每一页上添加它hook_init()
都是合适的:
function sessioncam_init() {
drupal_add_js(drupal_get_path('module', 'sessioncam') .'/sessioncam.js', array('type' => 'external', 'scope' => 'footer')) ;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
139 次 |
最近记录: |