Themes

Moodle 2 override default activities icons

 
 
Lei Zhang
Moodle 2 override default activities icons
 
Hi there, Is there anyway to override the activities icons in my custom theme folder without going to mod/activityname/pix folder? Thanks.


 
Average of ratings: -
It's only an avatar...
Re: Moodle 2 override default activities icons
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Which theme are you using? Some themes have pix/mod/activity/icons already installed into their theme folder. This is activated via the theme's config.php. Look for this in the config.php

$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?

Mary
 
Average of ratings: -
Lei Zhang
Re: Moodle 2 override default activities icons
 
Hi, Mary. Is moodle 2.0 still support custompix option? I'm working on a 2.0 theme based on formfactor.
 
Average of ratings: -
Sam Hemelryk
Re: Moodle 2 override default activities icons
Group DevelopersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers
Hi Lei,

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:
  1. Create the following directory within your themes directory: /pix_plugins/
  2. 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/
  3. Within that directory create another directory this time named after the plugin you want to override for example /forum/ for the forum activity.
  4. Copy your replacement image into that directory named the same as the image you are replacing.. most likely icon.xxx
  5. All done smile
For example overriding the forum icon you would end up with the following:
/moodle/theme/yourtheme/mod/forum/icon.gif

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 smile

I will post again with the relevant link to it once complete.

Cheers
Sam
 
Average of ratings:Useful (3)
Lei Zhang
Re: Moodle 2 override default activities icons
 
Hi Sam, that works! Thanks.


 
Average of ratings: -
Picture of peter gee
Re: Moodle 2 override default activities icons
 

for the book module i had better luck with moodle/theme/<themename>/pix_plugins/mod/book/

 
Average of ratings:Useful (1)
It's only an avatar...
Re: Moodle 2 override default activities icons
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Yes...this is an old discussion and you can tell what a rookie I was back then! smile

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.

Cheers

Mary

 
Average of ratings: -
Sam Hemelryk
Re: Moodle 2 override default activities icons
 
Average of ratings:Useful (2)
Richard
Re: Moodle 2 override default activities icons
 

Nice ! Thanks for this tutorial. I managed to make my icons in Moodle 2 look at lot prettier in only a few minutes.

 
Average of ratings: -
me
Re: Moodle 2 override default activities icons
 

Hi,

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,
Sam

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2 override default activities icons
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi Sam,

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

HTH

Mary

 
Average of ratings: -
me
Re: Moodle 2 override default activities icons
 

Hi Mary

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?

Sam

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2 override default activities icons
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Yes purging the cache with "Purge all cache" is performed on the server from within Moodle. So what you see on your local computer is what others will see.

HTH

Mary

 
Average of ratings: -
Picture of Ruth Cheesley
Re: Moodle 2 override default activities icons
 

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!

Ruth

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2 override default activities icons
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi,

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! smile

You will find FIREBUG an invaluable Add-On to Firefox, for hunting down the CSS for a specific element on the page.

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.

HTH

Mary

 
Average of ratings: -