Moodle 2 override default activities icons
$THEME->custompix = false;
/// If true, then this theme must have a "pix"
/// subdirectory that contains copies of all
/// files from the moodle/pix directory, plus a
/// "pix/mod" directory containing all the icons
/// for all the activity modules.
Hope this helps?
I will write a tutorial on it this morning it is very easy but I simply hadn't had a chance to document it yet.
In short follow these steps:
- Create the following directory within your themes directory: /pix_plugins/
- Within pix_plugins create a directory for the type of plugin you want to override in this case because you want to override an activity create a directory /mod/
- Within that directory create another directory this time named after the plugin you want to override for example /forum/ for the forum activity.
- Copy your replacement image into that directory named the same as the image you are replacing.. most likely icon.xxx
- All done
I should also mention that the extension of the image doesn't need to be the same. Moodle looks for gif, png, jpg, and jpeg extensions so as long as it is one of those it is fine
I will post again with the relevant link to it once complete.
for the book module i had better luck with moodle/theme/<themename>/pix_plugins/mod/book/
Yes...this is an old discussion and you can tell what a rookie I was back then!
You can see how all the MOD icons need to be added for them to be overridden by the theme by looking at the Afterburner theme HERE.
Nice ! Thanks for this tutorial. I managed to make my icons in Moodle 2 look at lot prettier in only a few minutes.
I am struggling with this. I am using the Splash theme. I checked the config.php file and it doesn't have the line: "$THEME->custompix = false;" within it.
Do I need to add this line in?
I also added the two folders pix_core and pix_plugins into my theme and this didn't seem to change it either. Do I need to reference these folders somewhere in the coding?
Any help will be very much appreciated.
Thank you in advance,
It all depends what you are trying to achive, as to how custom images work in Moodle 2.
First of all the Moodle 1.9 Custom Pix does not exist in Moodle 2. So forget that bit in the config.php.
Adding pix_core and pix_plugins is OK but if they are empty then Moodle will use the default pix icons for mods and activities and such from moodle/pix, moodle/mod, & moodle/enrol directories in your Moodle instalation.
Are you wanting to use your old set of icons from Moodle 1.9? If you are you need to copy these over to the relevent folders in your newly created pix_core and pix_plugins directories.
Also...if it is that you have done all this but are not seeing the benefit of these new icons this may be because you need to Purge all caches in Moodle. Site Administration > Development > Purge all caches
It was just that I needed to do the "Site Administration > Development > Purge all caches"
So will this be sorted for all our users who access our Moodle?
Huge thanks for the tutorial - nowhere near as complex as I had thought!
One question, I want to left-align the image so that the text does not flow underneath it, but can't find where to do this? I thought it'd be mod>resource>index.php but I don't seem to be able to change this. The string I found was this:
$icon = '<img src="'.$OUTPUT->pix_url($cm->icon).'" class="activityicon" alt="'.get_string('modulename', $cm->modname).'" /> ';
Any thoughts? Perhaps I am just getting the syntax wrong (I added align="left" after class="activityicon") but it's not having the desired effect even after purging cache (I've got dev mode enabled too).
Probs a very simple fix!
It is a simple fix but it all depends on where this particular 'icon' is. If it is a general one which is used throughout the site some simple CSS rule will fix it. If on the other-hand is just one specific icon you want to 'tweak' then you will need to apply an absolute path to the CSS to get it to respond to the rule set for it.
All your CSS files will be in moodle/theme/yourclonedthemename/style/... ....
Again depending on the theme you 'cloned' will depend on the file name for the theme, but generally the one you want is called core.css, unless it is one of my themes in which case it will be nameoftheme_styles.css, just to be different!
Is there a link to your site to view this icon? Or if you could upload a cut-down screenshot of this that would be great.