How to add renderers and templates to your Moodle Plugin – Tutorial by Mike Churchward #Moodledev

A Moodle renderer is a class that handles all the output for a component of Moodle and it should not contain any logic other than what is required to generate the display. This is the standard description of a Moodle renderer but how to make full use of the Moodle renderers and code the display logic for your plugin.

Introduced in Moodle 2.0, Moodle renderers are now expanded to make use of the templates, using the Mustache templating language. The use of templating language enabled the separation of HTML from PHP/JavaScript to allow the theme designers more creatively.

If you are also getting started with the Moodle theming and would like to learn about the renderers and templating then you can get started with this Moodle docs guide and this guide. However, if you would like to refer a practical hands on experience with overriding the renderers and templating mechanism in a plugin, then here is nice hands on tutorial for you.

The tutorial series written by Mike Churchward, Executive Director of POET group is good starting point for all Moodle theme designers who would like to get started with the Moodle renderers and templates. During the hands on experience tutorial, Mike refactored the “Questionnaire” plugin and improved the plugin output. The tutorial series covers the following topics:

There is another video demo by Damyon Wiese showing the JavaScript, Ajax and templates in Moodle recorded during the MoodleMoot Australia 2015 Hackfest. Check it out below:

 

Are you using the renderers in your Moodle plugin? Share your experience with us in the comments section below.

Jaswinder Singh

Jaswinder Singh, passionate about using Moodle in improving the Indian Education System and reaching the students in far flung areas where still education seems to be a impossible prospect of life. He is the author of the popular Moodle Book “How to use Moodle 2.7”. In October 2016, Jaswinder was elected as the Moodle User’s Association Committee member – the first to make it from India.

Related Articles