How can I add css to content created in cm_info_view ?

How can I add css to content created in cm_info_view ?

by Ludo M -
Number of replies: 2

Hello,

I am developping a mod plugin and I want to add a css for a div I display in the course page with the function myplugin_cm_info_view().
But I don't know how to do as I can't use

$PAGE->requires->css(new moodle_url('/mod/myplugin/styles/styles.css'));
since I understand that a CSS file cannot be required after <head> has been printed.

Average of ratings: -
In reply to Ludo M

Re: How can I add css to content created in cm_info_view ?

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators

Hi Ludo,

you just have to put your CSS into the file "/mod/yourplugin/styles.css". This file is loaded automatically. For the first usage or to apply changes to this file you have to delete your caches.

Best regards
Andreas

In reply to Andreas Grabs

Re: How can I add css to content created in cm_info_view ?

by Ludo M -

Hi Andreas,

Thank you, I just had to increment version of my plugin for the file to be loaded after the update plugin process.
(Deleting caches with the button didn't work for the first usage)