Attaching a javascript file on H5P pages in a custom module in drupal 8
Submitted by mayukhmohan on Wed, 06/06/2018 - 18:59
Forums:
I am creating a new module in which a have a js which i want to integrate on pages which have h5p content. At present I am using the hook element info alter as follows
function memodule_element_info_alter(array &$types)
{
if (isset($types['html']))
{ $types['html']['#attached']['library'][] = 'mymodule/mymodule';
}
}
I have used html as I was unable to find $type for h5p. html here attaches the js file to all pages. Can you help me with this problem? Is their another solution for including js in pages with h5p content.
icc
Thu, 06/07/2018 - 14:25
Permalink
Have you tried implementing
Have you tried implementing the hook_h5p_scripts_alter?
mayukhmohan
Fri, 06/08/2018 - 11:40
Permalink
I'm not getting how the
I'm not getting how the function is working i.e. what parameters are used and all that...Can you please elaborate?
Thank You...
icc
Wed, 06/13/2018 - 17:11
Permalink
Ah, I am sorry I did not
Ah, I am sorry I did not notice that it was for Drupal 8. I believe you should be using the hook_library_info_alter.
mayukhmohan
Mon, 06/18/2018 - 11:13
Permalink
Thanks, it worked.
Thanks, it worked.
raghav.bala
Mon, 06/10/2019 - 08:28
Permalink
Shall I get all code used in
Shall I get all code used in hook_library_info_alter.