## General developer forum

### Overriding function in boost theme

Overriding function in boost theme

Hi,

so the boost theme already extends the core renderer and the course_renderer. In "/theme/boost/classes/output/core/course_renderer.php" there is a custom version of the course_search_form() function which overrides the version in "/course/renderer.php".

Now I would like to add my custom version of the "get_category_formatted_description()" function which is also defined in "/course/renderer.php".

So I've copied the function into "/theme/boost/classes/output/core/course_renderer.php" and changed it slightly, but nothing happens. The changes are just ignored.

What am I doing wrong?

Here is the function (I've changed "return format_text($text,$descriptionformat, $options) to return format_text("MyCustomText",$descriptionformat, $options): /** * Returns formatted and filtered description of the given category * * @param coursecat$coursecat category

* @param stdClass|array $options format options, by default [noclean,overflowdiv], * if context is not specified it will be added automatically * @return string|null */ public function get_category_formatted_description($coursecat, $options = null) { if ($coursecat->id && !empty($coursecat->description)) { if (!isset($coursecat->descriptionformat)) {

$descriptionformat = FORMAT_MOODLE; } else {$descriptionformat = $coursecat->descriptionformat; } if ($options === null) {

$options = array('noclean' => true, 'overflowdiv' => true); } else {$options = (array)$options; }$context = context_coursecat::instance($coursecat->id); if (!isset($options['context'])) {

$options['context'] =$context;

}

$text = file_rewrite_pluginfile_urls($coursecat->description,

'pluginfile.php', $context->id, 'coursecat', 'description', null); return format_text("MyCustomText",$descriptionformat, \$options);

}

return null;

}

Average of ratings: -
Re: Overriding function in boost theme

It's because that function isn't in the core_course_renderer class. It's in the coursecat_helper class (in the same file).

I'm not sure how that would get overridden. Not sure it can.

Average of ratings: -
Re: Overriding function in boost theme

Thanks for the hint!

I've just given up, though. Without proper documentation this is just not doable with my limited programming skills.

Regards

Tobias

Average of ratings: -