Styles in CP Editor lost after update
Hi,
Recently updated H5P to 7.x-1.26 on our Drupal install. We had included some custom CSS and JS previously for the Course Presentation in a custom module as:
function cdclearning_h5p_styles_alter(&$styles, $libraries, $mode) { if (isset($libraries['H5P.CoursePresentation']) && $libraries['H5P.CoursePresentation']['majorVersion'] == '1'){ $styles[] = (object) array( // Path relative to drupal root 'path' => drupal_get_path('theme', 'cdc_platon') . '/css/eff_cp.css', // Cache buster 'version' => '?ver=2', );
(and the the script hook for the JS).
Previously the custom CSS and JS worked when both viewing the CP and when creating CP content with the editor.
However, now the editor doesn't pick up any of the CSS and JS files that were included. When saved and viewing the CP the CSS is applied correctly. But writing content semi-blind to how it will appear when saved is proving to be a bit of a headache!
Checking the <head> of the iframe shows the extra files when viewing the CP but not when on the editor page.
I've tried adding the hooks as described on: https://h5p.org/change-color-of-the-editor but even then I'm unsuccessful.
function cdclearning_h5p_scripts_alter(&$scripts, $libraries, $mode) { if ($mode == 'editor') { $scripts[] = (object) array( // Path relative to drupal root 'path' => drupal_get_path('theme', 'cdc_platon') . '/js/eff_h5peditor_html.js', // Cache buster 'version' => '?ver=2', ); } }
If you can spot anything I might have made a mistake with, or if the recent improvements to the editor require some extra steps, would really make my day!
Thanks!
fnoks
Mon, 03/06/2017 - 09:34
Permalink
Hi,Is your site set up to
Hi,
Is your site set up to aggregate JavaScript and CSS? If so, is it possible for you to test this without the aggregation enabled? Also, please check the Drupal's dblog (http://<yoursite>/admin/reports/dblog)
TomEff
Mon, 03/06/2017 - 14:07
Permalink
Ah, forgot had JS and CSS
Ah, forgot had JS and CSS aggregation turned on.
Looking through the logs, I get this warning for the files I'm trying to include:
"Warning: file_get_contents(sites/default/files/h5psites/default/themes/cdc_platon/css/eff_cp.css): failed to open stream: No such file or directory in H5PDefaultStorage->getContent() (line 288 of /srv/councilfordisabledchildren.org.uk/public/htdocs/sites/all/modules/h5p/library/h5p-default-storage.class.php)."
In the hooks though, the path im setting for the files to be included is: (I tried both approaches of using drupal_get_path and giving the full hardcoded path)
The watchdog returns the path as it should be:
Array ( [0] => stdClass Object ( [path] => sites/default/themes/cdc_platon/css/eff_cp.css [version] => ?ver=3 ) )
I'm not sure where the "sites/default/files/h5psites/" first part of path that is being included in the warning is being applied.
fnoks
Tue, 03/07/2017 - 10:58
Permalink
Thank you for your followup.
Thank you for your followup. What you are experiencing is a bug we actually fixed a few days ago, but it is not yet tested or released. In the meantime you could make the URL's to the files absolute (including scheme and domain), e.g:
This should fix it temporarily
TomEff
Tue, 03/07/2017 - 11:38
Permalink
Perfect, that's fixed it for
Perfect, that's fixed it for now!
Thank you very much for your help! :)
fnoks
Thu, 03/09/2017 - 09:45
Permalink
Good to hear :)
Good to hear :)