dongxiao1591 2016-02-03 19:35
浏览 71
已采纳

覆盖插件渲染器moodle

I have site running Moodle 2.9.3+ and i was trying to customize the renderer of one existing plugin, so i found this:

How to override a renderer such that the functionality of the overridden renderer also remains available?

I added the following into the core_renderer.php of my theme

include_once($CFG->dirroot . "/course/format/topcoll/renderer.php");

but when i tried to do

class topcoll_local_renderer extends format_topcoll_renderer {
  protected function section_header($section, $course, $onsectionpage, $sectionreturn = null) {
...
  }
}

it runs, but it's not loading the modified function. Do I need to do anything else? the modified function is running with no issues when I alter the code directly into the plugin, but not like this. I would greatly appreciate any possible hint.

Thanks

  • 写回答

2条回答 默认 最新

  • dongou3286 2016-02-03 20:47
    关注

    You need to do two things to get a theme renderer to override a core renderer:

    1. You need to edit the theme's config.php to add the line: $THEME->rendererfactory = 'theme_overridden_renderer_factory';
    2. You need to name your renderer class 'theme_NAMEOFTHEME_format_topcoll_renderer' (and extend 'format_topcoll_renderer', as you have done).

    The theme_overridden_renderer_factory works by extending the process of instantiating a renderer to look for a class that matches the name 'theme_NAMEOFTHEME_NAMEOFRENDERER' - as long as that class exists, then it should be used (otherwise the original renderer is used).

    See https://docs.moodle.org/dev/Overriding_a_renderer for more details.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案