How to override get_compact_logo_url

How to override get_compact_logo_url

by Javier Cuadrado -
Number of replies: 2

Hi,

I would like to add an image as a logo in my code.

I would like to override the variable $logo, and linked to an image that I have in the pix folder of my theme. ('http://localhost:8000/theme/javier/pix/i/logocompact.png').

I've added this to theme/{theme_name}/renderers.php but it doesn't work. 
I have already modified other functions on my thema, but I can't get this one to work. 

Any ideas?

Find my code below:

class theme_javier_renderer_base extends renderer_base {
    public function get_compact_logo_url($maxwidth = 300, $maxheight = 300) {
        global $CFG;
        $logo = 'http://localhost:8000/theme/javier/pix/i/logocompact.png';
        if (empty($logo)) {
            return false;
        }

        // Hide the requested size in the file path.
        $filepath = ((int) $maxwidth . 'x' . (int) $maxheight) . '/';

        // Use $CFG->themerev to prevent browser caching when the file changes.
        return moodle_url::make_pluginfile_url(context_system::instance()->id, 'core_admin', 'logocompact', $filepath,
            theme_get_revision(), $logo);
    }
}

Average of ratings: -
In reply to Javier Cuadrado

Re: How to override get_compact_logo_url

by Javier Cuadrado -
I get it to work when I add the following code directly in the lib/ouputrenderes.php

class theme_javier_renderer_base extends renderer_base {
    public function get_compact_logo_url($maxwidth = 300, $maxheight = 300) {
        global $CFG;
        $logo = 'http://localhost:8080/theme/javier/pix/i/logocompact.png';
        if (empty($logo)) {
            return false;
        }

        // Hide the requested size in the file path.
        $filepath = ((int) $maxwidth . 'x' . (int) $maxheight) . '/';

        // Use $CFG->themerev to prevent browser caching when the file changes.
        return 'http://localhost:8080/theme/javier/pix/i/logocompact.png';
    }

In reply to Javier Cuadrado

Re: How to override get_compact_logo_url

by Javier Cuadrado -
Ok, got it ! Here the solution:

class theme_{theme_name}_core_renderer extends core_renderer {