General developer forum

How can I add css to content created in cm_info_view ?

 
Picture of Ludo M
How can I add css to content created in cm_info_view ?
 

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: -
Picture of Andreas Grabs
Re: How can I add css to content created in cm_info_view ?
Core developersParticularly helpful MoodlersPlugin developersTranslators

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

 
Average of ratings: -
Picture of Ludo M
Re: How can I add css to content created in cm_info_view ?
 

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)

 
Average of ratings: -