Posts made by David Scotson

I was actually hoping that my theme would be able to pass control over to another theme, but that's not looking possible. Yours and Danny's suggestions are helpful, but are ways of having one theme behave differently depending on location within Moodle.

There's a function called resolve_theme in lib/pagelib.php which decides which theme to use based on all the various theme settings, and I can edit that to e.g. return a different theme based on the URL or whatever. But I can't override that from a theme, you need to edit core Moodle.

On the other hand I can override standard_head_html in a renderer, which means I can point to any CSS files I like and so could point to a different theme as long as it was installed. However, that "external" theme can influence the the layout file that is used, it has to use one from the current theme.

So I think the best I can do is to include a different theme's CSS based on whatever variables I want but require that the relevant admin.php layout from that theme is included in order for it to work.

It's good enough to experiment with and see if there's an easy way to divide Moodle into backstage admin settings and public theme'd sections and provide two seperate themes for each. If it works out then maybe a UI could be added and the change integrated into resolve_theme.

So any other suggestions for what divides backstage moodle from public facing moodle? I'll try having "admin" in the URL and having a layout of "admin", but I get the feeling it might devolve into a hand-picked list.

Moodle in English -> Themes -> Different Theme for Admin section ?

by David Scotson -
There's various ways in Moodle to change which theme is used e.g. you can have user themes, course themes, category themes, session themes based on the URL, device-specific themes based on user agent etc.

Is anyone aware of a simple way to set a different theme for admin sections, by which I probably mean anything with a url that starts with /admin/ but might be open to other solutions that approach this from a different angle.
Average of ratings: -

If you've already started with renderers then you can change the one called custom_menu, that's the one that decides whether or not to show the menu.

public function custom_menu($custommenuitems = '') {
   global $CFG;
    if (empty($custommenuitems)) {
        if (empty($CFG->custommenuitems)) {
            return '';
        } else {
            $custommenuitems = $CFG->custommenuitems;
        }
    }
    $custommenu = new custom_menu($custommenuitems, current_language());
    return $this->render_custom_menu($custommenu);
}
Average of ratings: Useful (1)

So I went back and checked my CSS for places where I'd had to "harmonise" a bunch of different classes, the big ones seem to be marking text as error/warning/success (i.e. red/yellow/green), various types of alert boxes, form layouts and tables.

Note this isn't CSS, it's LESS, basically saying apply the Bootstrap CSS inside the { } to all the classes named before it.

You can see the full file here: https://github.com/ds125v/gumoodle/blob/master/theme/bootstrap/less/moodle/patch.less

Currently I'm trying to fix the problem at the root by rewriting renderers so this HTML doesn't get written out in the first place, but particularly in forms that's not possible so once I've convinced myself I can't fix it in a renderer I'm patching it in a similar manner here:

https://github.com/ds125v/moodle-theme_bootstrap_renderers/tree/master/style/moodle


div.felement.error span.error,
span.error,
span.patherror,
tr.rolecap td.risk.xss a,
div.form-warning {
  .label-important
}
span.warn,
p.warn,
span.editinstructions,
#page-admin-report-security-index span.statuswarning,
span.statuswarning,
tr.rolecap td.risk.spam a,
.form-overridden {
  .label-warning
}
span.ok,
span.pathok,
span.statusok,
font[color="green"],
tr.rolecap td.risk.config a {
  .label-success
}

#page-admin-roles-assign h2 + .box.generalbox,
div.notifysuccess,
div.notifyproblem,
body.admin div.info,
div.box.copyright,
body.pagelayout-report div.info,
div.redirectmessage,
div.adminwarning,
div.forumnodiscuss,
div#notice p,
div.performanceinfo.pageinfo,
div.noticebox,
div#helppopupbox,
div.releasenoteslink,
.errorbox {
  .alert
}
a#closehelpbox {
  .alert .close
}

div.notifysuccess {
  .alert-success
}

#page-admin-roles-assign h2 + .box.generalbox,
div.notifyproblem,
.errorbox {
  .alert-error
}

body.admin div.info,
div.box.copyright,
div#helppopupbox,
div.redirectmessage,
body.pagelayout-report div.info,
div.releasenoteslink,
div.performanceinfo.pageinfo {
  .alert-info
}

/* just one example for forms */
#fgroup_id_buttonar,
#fitem_id_submitbutton,
table#form td.submit,
.form-buttons {
  .form-actions
}

table#explaincaps,
table#defineroletable,
table.grading-report,
table#listdirectories,
table.rolecaps,
table.userenrolment,
table#form,
form#movecourses table,
form#movecourses table,
#page-report-log-user .generaltable,
#page-admin-course-index .editcourse,
.forumheaderlist,
.userprofilebox table.list,
.generaltable {
    .table
}

Average of ratings: Useful (1)