General developer forum

Overriding a mod renderer in a Fordson child theme

Picture of Lea Cohen
Overriding a mod renderer in a Fordson child theme

I'm trying to override the mod_hvp_renderer in my theme but am not succeeding. My theme inherits from Fordson (which inherits from Boost).

There are instructions on how to override a renderer, but they apply to the way things were done before the new way that Boost introduced.

So these are the things that I'm not sure about:

  1. Location of class: I don't understand if my class should be located under:
    1. classes?
    2. classes -> output?
    3. classes -> output -> mod?
    4. classes -> output -> mod -> hvp?
  2. Name of file:
    1. Does the name of the file have to get the name of the class?
    2. Should it be called the name of the renderer - hvp_renderer, or perhaps mod_hvp_renderer?
    3. Should be called custom_renderer?
  3. Namespace: Should the class have a namespace?
  4. Name of class: Should the name of the class include the theme_mytheme prefix? I see that the renderers defined in Boost don't have it.

Any help or guidance will be greatly appreciated.

Average of ratings: -
Picture of Darko Miletić
Re: Overriding a mod renderer in a Fordson child theme
Core developersParticularly helpful Moodlers

Take a look again at

It states:

Renderers can also be used with code that uses namespaces. When creating or overriding new renderers with namespaces, be sure to use "output" as the second level namespace to comply with the rules for namespaces. Non-namespaced renderers can be overridden by a namespaced renderer and vice-versa - this leads to a complex search strategy when looking for overridden renderers.
You do not have to use autoloading namespaced classes.

If you really want to use that in your case you should:

Place the renderer file in the classes/output

File should be named mod_hvp_renderer.php

Inside you must specify appropriate namespace .

namespace theme_mytheme\output;

Class name should be mod_hvp_renderer and should extend \mod_hvp_renderer

Average of ratings: Useful (1)
Picture of Lea Cohen
Re: Overriding a mod renderer in a Fordson child theme

Thank you very much, it works now.

I appreciate your pointing me to the Namespaces part of the doc, but what really helped me was your detailed instructions which were tailored specifically for my case. Thank you very much!

Average of ratings: -