
Include CSS or JavaScript in Moodle
When writing a custom plugin, place CSS in a file called styles.css in the base directory of your plugin /plugin/styles.css. Moodle will automatically load the CSS file for you.
To include a CSS file in Moodle:
<?php $PAGE->requires->css(new moodle_url('/path/to/file.css')); ?>
To include a JavaScript file in Moodle:
<?php $PAGE->requires->js(new moodle_url('/path/to/file.js')); ?>
Provide the relative path to the file (excluding document root).
When writing a custom plugin, place CSS in a file called styles.css
in the base directory of your plugin /plugin/styles.css
. Moodle will automatically load the CSS file for you.
Did you like that post?
You can suscribe to the
RSS feed
or follow
@neatcoder
on Twitter
.