Adding .h5p activities programmatically to Drupal 8 nodes
Submitted by nschildre on Thu, 03/05/2020 - 20:42
Forums:
I am using the H5P Drupal 8 module and am trying to inserting .h5p zip archives into newly created nodes through a script in a custom module.
I have tried to use the following code and am passing (to my knowledge) a complete $h5p_content array:
$H5PObj = H5PDrupal::getInstance(); $result = $H5PObj->insertContent($h5p_content, $contentMainId = NULL);
Am I missing something ? Do I need to call another function aside from insertContent()?
I identified three tables that seemed to be important for h5P activities: h5p_content
, h5p_content_libraries
, and node__field_[field_name]
. node__field_[field_name] did not add a record after I called insertContent.
And even if I entered the relational record in that table manually, it still did not load the H5P activity in the newly created node.
Am I missing a table ?
Content types:
nschildre
Mon, 03/09/2020 - 16:14
Permalink
The insertContent function I
The insertContent function I am calling is from the official H5P Drupal 8 module.
nschildre
Sat, 04/04/2020 - 01:27
Permalink
Finally got it to work
See the discussion here:
https://www.drupal.org/project/h5p/issues/3111993