Load libaries dynamically

Forums: 

Hi all,
I use the content type H5P.Column several times in my content type H5P.RealityBox for structuring content.
These in turn can contain several different content types.
First of all it is not known from the beginning which content types are used in the columns. 
Furthermore, not all available content types, especially those that are not used, should be loaded. This would be the case when using preloadedDependencies.

How can it be done that available libraries can be loaded dynamically, like it is the case in H5P.InteractiveVideo?
And how can they be included in the h5p package, so that the content can be used elsewhere?

Kind regards
Johannes

Content types: 
otacke's picture

Hi Johannes!

Column already loads libraries as needed. You will notice that this is done by putting them as library options in semantics.json, not into library.json.

There's already a ticket on the H5P Jira, AFAIR, that deals with modifying semantics options of subcontent, but I don't know about the priority of that ticket.

A workaround is to create a custom editor widget / multiple custom editor widgets that removes libraries from the options of H5P Column when used as subcontent, cmp. https://github.com/otacke/h5p-editor-accordion for https://github.com/h5p/h5p-accordion/pull/41

Best,

Oliver 

Hi Oliver,
in semantic.json under library options H5P.Column 1.13 is specified. With the help of H5PEditor and H5P.DragNBar.FormManager it is possible to load and edit a column in the editor.

When I save the content and try to create a column with H5P.newRunnable in H5P.RealityBox I get the following error:

Unable to find constructor for: H5P.Column 1.13


And accordingly then:

Uncaught TypeError: Cannot read property 'attach' of undefined

 

Kind regards
Johannes

otacke's picture

Sorry, I don't have the time to dig through code. Not sure why that library isn't loading.

Hi Oliver,
thanks for your help.

My h5p.classes.php had a mistake at one place.
I found it out while comparing it with the file available on Github.

Kind regards
Johannes

Kind regards

otacke's picture

Phew! Thanks for letting me know. I might have had trouble finding that and would have gone grey over it ;-)