Overriding myprofile renderer

Overriding myprofile renderer

by Cristian Martin Nieto -
Number of replies: 3

Hello there,

I would like to customize a bit the profile page (removing some sections, adding others), and I assumed the way to proceed was to override the myprofile renderer. However, when I try to do it, my site shows a 503 error without any error logs. Can someone give me any hints on what I am doing wrong?


The way I tried doing it was adding this to config.php in my theme:

$THEME->rendererfactory = 'theme_overriden_renderer_factory';

And this to my renderers.php:

use core_user\output\myprofile\tree as tree;
use core_user\output\myprofile\renderer as renderer;

class theme_custom_core_renderer extends renderer {
    
    public function render_tree(tree $tree) {
        return parent::render_tree($tree);
    }
}

Oh, and I am using Moodle 3.0.

Average of ratings: -
In reply to Cristian Martin Nieto

Re: Overriding myprofile renderer

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

You could take a look at flexibase where I over-rode the my profile renderer - specifically the public function render_category  (with help from Mary and Gareth to find how to do it with the newer classes folders such as the one the my profile renderer uses)

I put it in a classes folder to mirror its original location

/flexibase/classes/output/core_user/myprofile

and then the file starts (after the licence info etc)

namespace theme_flexibase\output\core_user\myprofile;
use \core_user\output\myprofile\category;

defined('MOODLE_INTERNAL') || die();
class renderer extends \core_user\output\myprofile\renderer {

public function render_category(category $category) {

You can find it at

https://github.com/roelmann/moodle-theme_flexibase/blob/master/classes/output/core_user/myprofile/renderer.php

Hope that helps

Richard


Average of ratings: Useful (3)
In reply to Richard Oelmann

Re: Overriding myprofile renderer

by Cristian Martin Nieto -

Richard, that was EXACTLY the answer I was looking for.  As soon as I changed the folder structure (and the filenames), moodle picked up my renderer again.

Thank you very much!!!