Open r-kraemer opened 2 years ago
Hi, as we had the urgent need to solve this issue, we created an extension that extends the class site/typo3conf/ext/cb_h5p/Classes/Controller/ViewController.php from the h5p extension as a temporary fix. Not only the error "only one instance of babel-polyfill is allowed" happens, but also a 2nd error "Uncaught TypeError: i.metadata is undefined" appears. Only this 2nd error prevents interactiveBooks from showing in the frontend!
We only overwrote and adjusted the indexAction in our extension with the following lines:
// Fix for error: "i.metadata is undefined"
// add missing metadata from DB field parameters:
if(!key_exists('metadata',$contentSettings)){
$h5pParameters = json_decode($content->getParameters());
if($h5pParameters->metadata){
$contentSettings['metadata'] = $h5pParameters->metadata;
}else{
// if no metadata is available in DB data, initialise with empty array
$contentSettings['metadata'] = array();
}
}
// Fix for error: "Only one instance of babel-polyfill is allowed" => remove h5p-interactive-book.js duplicate from scripts array
// $contentSettings['scripts'] array contains twice: "/fileadmin/h5p/libraries/H5P.InteractiveBook-1.5/dist/h5p-interactive-book.js?v=0.3.0"
//check if h5p-interactive-book.js is in the array more then once => if yes, remove duplicate
$found = false;
foreach($contentSettings['scripts'] as $key => $value){
if(strpos($value,'h5p-interactive-book.js') > 0){
if($found == false){
$found = true;
}else{
unset($contentSettings['scripts'][$key]);
break;
}
}
}
Note: a more generic approach to remove script duplicates like array_unique($contentSettings['scripts']); did not work!
Maybe this fix can be added to the original extension or rather used as a basis for a more elegant solution ;-)
Regards! Ulrike
Hello Ulrike, kindly share the customised ViewController.php, thank you
Here you go ;-) cb_h5p.zip
thank you!
Hi, the Content Type "Interactive Book" is quite useful and versatile. However it will not display/render properly, pls. refer to the screenshot of the console output.
Typo3 Version 11.5.8, H5P Version 11.5.10