简体   繁体   English

Drupal 7将jQuery添加到模块

[英]Drupal 7 adding jQuery to a Module

I have been searching for a method to accomplish a goal for several days. 我一直在寻找一种方法来完成目标几天。

What I would like to do is use a jQuery library (flot) inside of a Drupal 7 Module that I have written. 我想做的是在我编写的Drupal 7模块内部使用jQuery库(flot)。

Here is what I think I need to do and the reasons I am confused about implementing it. 这是我认为我需要做的事情,以及我对其实施感到困惑的原因。

  1. include the flot library in the module folder. 在模块文件夹中包含flot库。 -I haven't found any information that suggests if this is the correct place to store the files. -我还没有发现任何暗示此文件存储位置正确的信息。

  2. Include the flot module some how in the module in one of the hook functions. 将flot模块包括在钩子功能之一中的模块中。 -The resources I have found are not clear as to which hook function the module should be included from. -我发现的资源不清楚该模块应包含在哪个挂钩函数中。

  3. Write the associated jquery to display a chart using flot. 编写关联的jquery以使用flot显示图表。 -I think this should be done in the function where the page is described, but I can't find a tutorial or reference where this is done. -我认为应该在描述页面的函数中完成此操作,但是我找不到完成此操作的教程或参考。

Thanks for any help clarifying this that you can provide. 感谢您提供任何帮助,以澄清您可以提供的信息。

I would include the flot files in a subdirectory of your module, to allow for easier updating. 我会将flot文件包含在模块的子目录中,以便于更轻松地更新。 Alternately you could include instructions on how to download the files from the flot git repo. 或者,您可以包括有关如何从flot git repo下载文件的说明。

If you plan to distribute this module on drupal.org, I believe that you should be able to re-license flot to be GPL, which is required to put the code in the Drupal repo ( source. ) 如果您打算在drupal.org上分发此模块,我相信您应该能够将flot重新许可为GPL,这是将代码放入Drupal存储库中所必需的( 源)。

Additionally, I would look at the jQuery Plugin Module as a reference of where to place jQuery plugin files inside your module directory structure. 此外,我将看一下jQuery插件模块,作为在模块目录结构中放置jQuery插件文件的位置的参考。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM