Best practice forum (Archived)

Upgrade to 2.5 Broke my Logo based on Custom Totara

 
A Eisenberg
Upgrade to 2.5 Broke my Logo based on Custom Totara
by Alan Eisenberg - Friday, 13 December 2013, 6:47 AM
 

We are in the process of upgrading our site from 2.4.13 to 2.5. I had made a custom theme based on the Totara Custom theme that worked fine in 2.4.13 to be able to upload both the logo and the Favicon in the theme area.

Upon upgrade, though now, the logo I would see in the upper left of the screen is now a broken graphic icon and I can go to the theme and update those items, but they remain broken in the page. I am wondering what changed in theme between 2.4 and 2.5? Do I have to go back and build the theme from scratch again?

I switched the theme to the new Custom Totara one and tried updating the Logo in there and it worked fine, so I'm not sure why it's not working for me in my old version of the theme.

The only workaround I could figure out was to manually change the code on the layout pages and put the graphic on the site and reference it from there. When I did that it worked, but it seems like I should have been able to update them from within the Logo and Favicon areas in the theme area for that theme.

I have attached what it looks like now where the logo should be so you can see it as well.

Also, I want to hide the Appraisals area for now on the top menu and I need to add another item ("help") to the "My Learning" menu. In the new Totara 2.5, how can I do that? Thank you.

Any/all advice or help is appreciated.

b/r,

Alan


Ciaran Irvine (Core Developer)
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Ciaran Irvine (Core Developer) - Sunday, 15 December 2013, 2:37 PM
 

Hi Alan,

I think in 2.5 one of the theme admin settings changed. The 2.4 version for the logo picker in your theme/settings.php would have been something like

$setting = new admin_setting_configfilepicker($name, $title, $description, $default, array('web_image'));

but the 2.5 version is

$setting = new admin_setting_configstoredfile($name, $title, $description, 'logo');

 

Making that change should fix your custom theme, I think.

The Totara menu is defined in totara/core/totara.php in the function totara_build_menu() so that is where you would need to make code changes to add or remove items from the standard menu. There is an outstanding feature request to make the menu fully customisable through a web interface, but it is very unlikely that this will make it into Totara core before 2.6 at the earliest.

A Eisenberg
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Alan Eisenberg - Monday, 16 December 2013, 5:03 AM
 

Hi Ciaran:

I wish I could tell you this worked, but I get the feeling there are many other places where changes are just in the theme/settings.php area alone. I got it to work, but manually changing the code on the layouts to call directly to the graphic, but that does not seem like the right idea as I expect the code to update again.

If someone customized a Totara Custom 2.4 theme, can anyone explain what needs to be fixed in order to update those to a 2.5 theme? We have done a lot of theme customization and want to make sure everything works as it is supposed to.

Thank you, though, for the the top menu advice. I did get that to work. Any further help on theme updating would be great though.

Alan

Ciaran Irvine (Core Developer)
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Ciaran Irvine (Core Developer) - Monday, 16 December 2013, 7:25 PM
 

Hi Alan,

I've gone through all the changes in the base customtotara from 2.4 to 2.5. You are right, there are some code changes. You will probably need to be change all these as well in your 2.5 theme - replace customtotara with the directory your theme is in in all the lines below:

 

/theme/customtotara/config.php change the last line

$THEME->csspostprocess = 'customtotara_process_css';

to

$THEME->csspostprocess = 'theme_customtotara_process_css';

 

theme/customtotara/lib.php, Rename

function customtotara_process_css($css, $theme) {

to

function theme_customtotara_process_css($css, $theme) {

And in that function on the second-last line change

$css = customtotara_set_customcss($css, $customcss); 

to

$css = theme_customtotara_set_customcss($css, $customcss);

 

Still in lib.php, Rename

function customtotara_set_customcss($css, $customcss) {

to

function theme_customtotara_set_customcss($css, $customcss) {

 

Immediately after function theme_customtotara_set_customcss add a new function:

/**
 * Serves any files associated with the theme settings.
 *
 * @param stdClass $course
 * @param stdClass $cm
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @param array $options
 * @return bool
 */
function theme_customtotara_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
    if ($context->contextlevel == CONTEXT_SYSTEM && ($filearea === 'logo' || $filearea === 'favicon')) {
        $theme = theme_config::load('customtotara');
        return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
    } else {
        send_file_not_found();
    }

 

And lastly, in settings.php where you changed "new admin_setting_configfilepicker" to "new admin_setting_configstoredfile" in my first reply, you should add the line

$setting->set_updatedcallback('theme_reset_all_caches');

This line should also be added after all the $setting = new admin_setting_* lines in that file - 7 of them in the base standardtotara.

 

If all that works then I'll put together instructions for all the clients who may have 2.4 custom themes as I can see this being a problem for quite a few clients.

A Eisenberg
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Alan Eisenberg - Tuesday, 17 December 2013, 4:45 AM
 

Ciaran:

Great. Will try today. Much like what we used before that Moodle had developed at:

http://docs.moodle.org/dev/Themes_2.2_how_to_clone_a_Moodle_2.2_theme

We need the same for Totara and on these upgrades one for how to upgrade as you explained above. I will try that and see if it works for our design. Thank you.

Alan

A Eisenberg
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Alan Eisenberg - Tuesday, 17 December 2013, 5:11 AM
 

I should also note that I did bring in the layouts from Standard Totara for my design, because I wanted to make them more 508 compliant and the Customtotara did not include the layouts. Let me know if I should expect to have to make any major changes to those as well.

I can always bring in the new StandardTotara layouts to work with, but would prefer to minimize changes.

Alan

A Eisenberg
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Alan Eisenberg - Tuesday, 17 December 2013, 9:14 AM
 

Ciaran:

This didn't work. I did all the changes and then saved and added the new layout. When I went to switch to the new layout, I just got a white screen and it didn't give me the layout change option. At this point I have updated my 2.4 to work, but don't know with these code changes if that is the best idea.

Also, I have to ask that by adding the layouts in my 2.4 design, could that be breaking something. There may be other changes that are affecting it as well. But the instructions above definitely didn't bring it back to square.Seems there may be more to this, depending on the complexities of the changes made. As I said, I did some manual changes to the layout code and CSS and that fixed my 2.4 problems. But is there updated code in the 2.5 settings that I am now losing due to not updating? Is that going to cost me in the end?

Alan

Richard House
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Richard House - Tuesday, 17 December 2013, 12:05 PM
 

Hi Ciaran,

We experienced a similar problem upgrading a stock Totara 2.4 to 2.5, with no customized themes. The upgrade seemed to loose the theme settings made by the admin (in this case colours) and the link to the logo image they uploaded. These had to be reset.

Regards,

Richard

Ciaran Irvine (Core Developer)
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Ciaran Irvine (Core Developer) - Tuesday, 17 December 2013, 3:07 PM
 

Hi Richard,

I'm not surprised by the logo, because the way the theme logos are uploaded and stored radically changed in Moodle and I'm not really sure if we can add anything to the upgrade script to migrate the logos properly, though we will look into it.

Other non-file settings like the colours though should definitely have been migrated so there may be a different, if related, bug there.

Ciaran Irvine (Core Developer)
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Ciaran Irvine (Core Developer) - Tuesday, 17 December 2013, 3:03 PM
 

Hi Alan,

Did you try turning on debugging to see if there was an error message on the white screen? You should take a clean copy of the old working 2.4 theme from the original 2.4 install, add the theme directory to 2.5, make the changes above (and no others), turn on debugging, and see what happens. You may still have to reset the logo in the theme settings because of the new logo filepicker.

Unfortunately without actually having your custom theme code it's almost impossible to try and diagnose the problem from here. If your theme is mainly just CSS and image changes to the base customtotara then alternatively it should be relatively straightforward to apply those changes on top of a copy of the 2.5 version of customtotara. However if it is a heavily customised theme with lots of custom code then there will probably always be issues with such a theme on every major version upgrade, depending on what changes Moodle have made.

A Eisenberg
Re: Upgrade to 2.5 Broke my Logo based on Custom Totara
by Alan Eisenberg - Wednesday, 18 December 2013, 4:40 AM
 

Hi Ciaran:

I ended up doing just that and using the Custom Totara 2.5 theme and updating it with my code updates from 2.4. As I said, I think that the fact that Custom Totara does not have the LAYOUT folder and that you must add that from Standard Totara creates a bit of an issue.

It would seem to me that people would want to change (especially those of us that are 508 compliancy and disability conscious) to the Layouts, because they are not fully compliant (LOGO in particular, see that alt=logo will not pace a compliance test).

So, I went and copied the new 2.5 custom totara, applied my old CSS, brought in the layouts from my standard totara, updated the layouts and my CSS as needed and got it working. But again, I think any instructions, particularly on theme cloning, would be helpful. Things like knowing where to add the CSS in the config.php and how the order works is important I would think.

As we get into responsive themes in the near future with Totara (I hope), this will become more critical. While many of the companies probably have great PHP people, I know some have designers that need to know only what they need to know to clone and update a layout.

Any and all help to get directions to do so, particularly when an upgrade affects a layout like 2.5 did. Thanks for all the help. Let me know if there are plans to help people by creating some cloning directions specific for Totara Custom, etc.

b/r,

Alan