Login page theming (theme class override)

Re: Login page theming (theme class override)

by Gareth J Barnard -
Number of replies: 1
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

How do you know your 'export_for_template' is not actually being called but not using your template?....

But then in 'outputrenderers.php' there is:

    /**
     * Renders the login form.
     *
     * @param \core_auth\output\login $form The renderable.
     * @return string
     */
    public function render_login(\core_auth\output\login $form) {
        $context = $form->export_for_template($this);
        // Override because rendering is not supported in template yet.
        $context->cookieshelpiconformatted = $this->help_icon('cookiesenabled');
        $context->errorformatted = $this->error_text($context->error);
        return $this->render_from_template('core/loginform', $context);
    }

so no autoloading but fixed class names and specifically located template.  Which if I'm wrong and the class you have is autoloaded, will still mean that the template is not yours so the additional context data will be unused.

In reply to Gareth J Barnard

Re: Login page theming (theme class override)

by Didier Raboud -
How do you know your 'export_for_template' is not actually being called but not using your template?....

I tested smile

The template is not fixed (it's not a fullpath, but a template name); and render_from_template will use the correct template, I tested that as well.

My understanding is that themes are allowed to override renderers only, through theme_overridden_renderer_factory, but not arbitrary functions.

But you put me on the right tracks: by overriding render_login in the theme_xxx/classes/core_renderer.php's theme_fhsg_core_renderer class, one can achieve what they want without a core hack. Thanks!