Elegance Custom Categories Icons

Elegance Custom Categories Icons

by Argenis Alvarez -
Number of replies: 24

Hello, glad to participate and thanks for the Theme it is really cool and hard worked congratulations.

I´m twiking the theme like all do and I found some trouble when y try to costumize the icons in or for each category...  (at least in theory like the theme let me do).  but it doesn´t show the icons I had select for each of the categories (it leave the default one). Perhaps am I doing something wrong?

This is so simple but I´m a little frustrated cause I can´t find the solution.

 

I´ll appreciate your help in this matter

Thanks.

 

Images for reference

Attachment help.jpg
Average of ratings: -
In reply to Argenis Alvarez

Re: Elegance Custom Categories Icons

by Argenis Alvarez -

Hello,

I´m not using an internal network I´m testing it online in a live hosting, I don´t use IE, I´m testing it in Firefox, Chrome and Safari, but it does not show the icons I just made an "Fix" meanwhile I will be able to find why is not working.

"Fix" at the css: ".course_category_tree .category[data-categoryid="1"]>.info>.categoryname a:before {
content: "\f0ae";
}"

For every category with it respective content data.

Thanks

In reply to Argenis Alvarez

Re: Elegance Custom Categories Icons

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Not 100% sure as I haven't had chance to test it, but it looks as if there is a bug in the settings array for the category items which might be 'killing' the selector array

https://github.com/moodleman/moodle-theme_elegance/blob/master/settings.php#L1158

     'f0e3,a-gavel',

 should probably be

     'f0e3'=>'fa-gavel',

 Also:

https://github.com/moodleman/moodle-theme_elegance/blob/master/settings.php#L1138

https://github.com/moodleman/moodle-theme_elegance/blob/master/settings.php#L1566

and

https://github.com/moodleman/moodle-theme_elegance/blob/master/settings.php#L1586

EDIT: Tested with those typos corrected - category icons still picking up just default

Average of ratings: Useful (1)
In reply to Richard Oelmann

Re: Elegance Custom Categories Icons

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

https://github.com/moodleman/moodle-theme_elegance/blob/master/lib.php#L107

        if (!empty($theme->settings->usecategoryicon)) {

 Should read

        if (!empty($theme->settings->enablecategoryicon)) {

 

Average of ratings: Useful (2)
In reply to Richard Oelmann

Re: Elegance Custom Categories Icons

by Danny Wahl -

I can make a pull request for this on Monday unless you want to ;)

In reply to Danny Wahl

Re: Elegance Custom Categories Icons

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

I'll try to do it later today Danny, but at the moment Im setting up a new laptop from work so I need to get my git repositories all set back up on here first, so if I don't get it done, feel free smile

In reply to Richard Oelmann

Re: Elegance Custom Categories Icons

by Carl Durose -

Thanks, that sorted the issue straight away.

If only we could apply the category icons to more then 20 categories - or find a way to group the sub categories within the parent category so as they all display the icons?

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Carl Durose -

In line 105 of lib.php, I tried changing 

foreach (range(1, 20) as $categorynumber) {

to 

foreach (range(1, 90) as $categorynumber) {

I’m guessing one needs to change the value of the drop down form on the [Site Administration / Appearance / Themes / Elegance / Category Icons] page somewhere too.

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Carl Durose -

Figured it out; in settings.php from line 1356 just increase the number values as far as you wish.

'21'=>'21',
'22'=>'22',
'23'=>'23',
'24'=>'24',
'25'=>'25',
'26'=>'26',
'27'=>'27',

);

 

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Carl Durose -

This didn’t work quite as simply as I believed.

I entered numbers to 100 on lib.php and settings.php as mentioned above.

I was able to assign each category an icon, but upon saving only categories upto 20 were assigned an icon other than the default.

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

I just got this to work...so not sure what it is you did wrong, unless you forgot to set the overall category number that sets the other fields?

theme_elegance | categorynumber

Default: 1

Number of category icons will not change until you hit save after changing this number

Alternatively you might have an error in the code so best to turn on Debuggin in..

Site Administration > Development > Debugging. (DEVELOPER) setting

In reply to Mary Evans

Re: Elegance Custom Categories Icons

by Carl Durose -

I have the number of categories selected at 91.

One can only assign icons to the number of categories selected.

Perhaps I tried to increase it by too many at once?

Put developer debugging on, nothings come up.

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I think that if you change any of the code in 'settings.php' then you have to up the version number in 'version.php' to perform an upgrade and update things in the database.

With the 'no of' type settings they work without version increments because the code takes the value and adds new settings to the database if they are not already there, so if you increase one, set some values, decrease and re-increase again then you should find your values already there instead of the defaults.

In reply to Gareth J Barnard

Re: Elegance Custom Categories Icons

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

That is not so Gareth, I just added the changes to the settings.php and to the lib.php and everything worked straight away.

In reply to Mary Evans

Re: Elegance Custom Categories Icons

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Oh ok smile - perhaps a 'purge all caches' thing.  My gut thought it was the case though.

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Here's the settings page I added...

And this is the change I made to the lib.php file

    // Set Category Icons.
    foreach (range(1, 100) as $categorynumber) {
        $categoryicon = $defaultcategoryicon;
        if (!empty($theme->settings->usecategoryicon)) {
            if (!empty($theme->settings->{'categoryicon' . $categorynumber})) {
                $categoryicon = $theme->settings->{'categoryicon' . $categorynumber};
            }
        }
        $css = theme_elegance_set_categoryicon($css, $categoryicon, $categorynumber);
    }

In reply to Mary Evans

Re: Elegance Custom Categories Icons

by Carl Durose -

I still couldn’t get it to work. I couldn’t notice any changes between your lib.php code and my own. I copied and pasted yours into mine just incase. Have purged all caches. Still just showing ‘default icon’. sad

Just a thought: I don’t have any categories in existence between 20 and 34 as a couple of obsolete parent category have been deleted along with several subs. Would this effect it at all?

 

(btw, your settings.php link is broken Mary)

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Come on...what is this a mind game?

Either you have the Categories or you don't.

If they don't exist then they will not show.

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Changing settings.php and lib.php will get the settings into the array - but don't forget you actually need to apply those changes to the css

Take a look at /styles/categories.css - you'll see a line there for every category (upto 20) You'll have to extend that as far as you want it to go

/* Upload the image from each category */
.course_category_tree .category[data-categoryid="1"]>.info>.categoryname a:before {
content: "\setting:categoryicon1";
}
.course_category_tree .category[data-categoryid="2"]>.info>.categoryname a:before {
content: "\setting:categoryicon2";
}
Average of ratings: Useful (1)
In reply to Richard Oelmann

Re: Elegance Custom Categories Icons

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

The list in the CSS goes up to 39..(I seem to recall) over 20 anyway.

I seem to be at cross purposes with this thread as I was under the impression that Carl could not get the list to work.

There is some missing code in the lib.pp which needs fixing.

there should be an easier way to get the CSS to work without all those settings. This sort of thing could be done in a renderer where the category is created, a bit like the Custom Menu.

I'm tired and was working on other stuff...this is too too confusing at this time of the day.

Apologies if I seem a bit off...I am LOL

In reply to Mary Evans

Re: Elegance Custom Categories Icons

by Carl Durose -

from your code I had to change 

      if (!empty($theme->settings->usecategoryicon)) {

to

        if (!empty($theme->settings->enablecategoryicon)) {

as per conversation above.

In reply to Carl Durose

Re: Elegance Custom Categories Icons

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

That change only makes the correct image show up, that is not what I was testing. I thought you were only concerned about the list of categories? Please tell me if that is working now?

In reply to Mary Evans

Re: Elegance Custom Categories Icons

by Carl Durose -

Sorry was away from my computer/desk yesterday.

YES! With the addition of the code in the categories.css it is fully functioning.

Many thanks to all! smile