Reputation: 3984
i am trying to change the left drawer contents in moodle 4.0 when the user is viewing the course. this shows a list of the course modules.
i have a custom theme that extends the boost theme.
i have found the file/method that i want to overload: which is /course/format/classes/output/local/state/cm.php/cm.php and the method::export_for_template
this left drawer content is not rendered by the navigated page (course/view.php), but rather it is rendered from a call to /lib/ajax/service.php?sesskey=Cwqs0UlcLu&info=core_courseformat_get_state. this call only occurs when the caches have been purged. /lib/ajax/service.php returns json data of the course content hierarchy with a mustache template that is presumably rendered by injecting the content into the DOM by the browser.
what i have tried:
my theme has $THEME->rendererfactory = 'theme_overridden_renderer_factory';
and i have a mytheme/renders.php file that in part has :
require_once($CFG->dirroot . '/course/format/classes/output/local/state/cm.php');
class theme_mytheme_core_courseformat_output_local_state_cm extends core_courseformat\output\local\state\cm{
...
}
but that didn't work.
what does work
i can overload the mustache template in /theme/mytheme/templates/core_courseformat/local/courseindex/cm.mustache
but i want to mutate the data, not change the way it is displayed.
my question is:
how can i overload the cm::export_for_template method in my template so I can mutate the data shown in the left drawer when in course view?
Upvotes: 1
Views: 517