首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将js添加到H5P embed.php文件中?

如何将js添加到H5P embed.php文件中?
EN

Drupal用户
提问于 2018-08-22 21:04:47
回答 1查看 125关注 0票数 0

H5P模块创建iframe并在iframe中显示内容。我需要在iframe中添加一个js文件,但是我做不到。

在文档中,有一个如何向h5p添加js的示例:

代码语言:javascript
复制
/**
 * Add scripts to h5ps
 *
 * @param array $scripts
 *  Array of objects with properties path and version. Version is on the form
 *  ?ver=1.0.2 and is used as a cache buster
 * @param array $libraries
 *  Array of libraries indexed by the library's machineName and with an array
 *  as value. The value has the properties majorVersion and minorVersion
 * @param string $mode
 *  What mode are we in? Possible values are "editor", "div", "iframe" and "external"
 */
function hook_h5p_scripts_alter(&$scripts, $libraries, $mode) {
  if (isset($libraries['H5P.MultiChoice']) && $libraries['H5P.MultiChoice']['majorVersion'] == '1') {
    $scripts[] = (object) array(
      // Path relative to drupal root
      'path' => drupal_get_path('module', 'mymodule') . '/h5p-overrides.js',
      // Cache buster
      'version' => '?ver=1',
    );
  }
}

我已经创建了一个模块,在.module文件中添加了这个脚本并创建了overrides.js。但我无法让它工作,js文件没有添加。除了上面的脚本之外,我还应该在.module文件中添加什么呢?

EN

回答 1

Drupal用户

发布于 2018-08-22 21:31:49

您需要用模块名替换钩子。以及玛莫杜莱。

票数 0
EN
页面原文内容由Drupal提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://drupal.stackexchange.com/questions/268007

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档