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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退