H5P模块创建iframe并在iframe中显示内容。我需要在iframe中添加一个js文件,但是我做不到。
在文档中,有一个如何向h5p添加js的示例:
/**
* 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文件中添加什么呢?
发布于 2018-08-22 21:31:49
您需要用模块名替换钩子。以及玛莫杜莱。
https://drupal.stackexchange.com/questions/268007
复制相似问题