Overriding a core template called from javascript

Overriding a core template called from javascript

by olivier Dechepy -
Number of replies: 0


I'm using Moodle 3.5 ATM, and i'm using a child theme of Fordson.

I would like to have the link "reset user tour" which is by defaut in the footer, put elsewhere AND instead of a text  "Reset user tour on this page", I would like a button.

The template is located in admin/tool/usertours/resettour.mustache, and has no variable (except traduction string)

I didn't find any renderer, but it is called from javascript in admin/tool/usertours/amd/src/usertours.js in the addResetLink method

addResetLink: function() {
 var ele;
 M.util.js_pending('admin_usertour_addResetLink');
// Append the link to the most suitable place on the page
// with fallback to legacy selectors and finally the body
// if there is no better place.
 if ($('.tool_usertours-resettourcontainer').length) {
   ele = $('.tool_usertours-resettourcontainer');
 } else if ($('.logininfo').length) {
   ele = $('.logininfo');
 } else if ($('footer').length) {
   ele = $('footer');
 } else {
   ele = $('body');
 }
 templates.render('tool_usertours/resettour', {})
  .then(function(html, js) {
    templates.appendNodeContents(ele, html, js);
    return;
 })
 .always(function() {
   M.util.js_complete('admin_usertour_addResetLink');
   return;
 })
 .fail();
},

So, i have several questions : 
1 - Obviously : is it possible to override tools templates ? If so

2- should i place my template in /theme/mytheme/templates/tool/usertours/resettour.mustache or somewhere else ? (i've tried but it's not enough AFAIK) - as suggest the documentation

3 - since this templates is called from js, can i override this /tool/usertours/amd/src/usertours.js in my theme ? where should i put it ? How to override such a javascript class method (redeclaring it) ?


Thank you for any help 

Average of ratings: -