While implementing a lightweight theme inheriting from Boost, I stumbled upon a change I didn't manage to do cleanly without a core patch.
The idea is to prominently propose Shibboleth login without using $CFG->alternateloginurl, producing something along these lines →
As I didn't want to put that code in the mustache template (because that's WAYF code handled by a block, here's what I did:
- Added theme/xxx/templates/core/loginform.mustache with a variable addition:
(…)
{{#mycontent}}
<div>{{{ mycontent }}}</div>
{{/mycontent}}
(…)
- Created theme/xxx/classes/core_auth/output/login.php with this:
<?php
namespace theme_xxx\core_auth\output;
require_once($CFG->libdir . '/externallib.php');
use renderer_base;
class login extends \core_auth\output\login {
public function export_for_template(renderer_base $output) {
global $CFG, $PAGE;
$data = parent::export_for_template($output);
// Add my content here; assume it's not possible in a mustache template
$data->mycontent = rand();
return $data;
}
} - Then I expected that \theme_xxx\core_auth\output\login class to be used from /login/index.php automagically
- … it doesn't work, so I had to patch /login/index.php with this:
} else {
- $loginform = new \core_auth\output\login($authsequence, $frm->username);
+ if ($PAGE->theme->name == 'xxx') {
+ $loginform = new \theme_xxx\core_auth\output\login($authsequence, $frm->username);
+ } else {
+ $loginform = new \core_auth\output\login($authsequence, $frm->username);
+ }
$loginform->set_error($errormsg);