grabs / moodle-mod_unilabel

1 stars 10 forks source link

Overriding plugin templates through theme #21

Closed VOOM108 closed 2 years ago

VOOM108 commented 3 years ago

I am trying to override plugin templates by putting them into the theme folder /templates/....

Moodle does not document how to override plugin templates, that reside unter a subdir in the plugin template folder like /mod/unilabel/type/carousel/templates

I tried /theme/boost/templates/mod_unilabel/carousel.mustache as well as /mod_unilabel_type_carousel/carousel.mustache or /mod_unilabel/type/carousel/carousel.mustache and other ways. Nothing seems to work.

Can you help?

Additionally a feature request: what I am trying to do is simply add a carousel-fade class to the template. It would be great to have theme options to change transition type from slide to others like fade... :)

grabs commented 3 years ago

Hi, you must not see the subplugins as a directory. A subplugin can be overriden like any other plugin. That means you have to create a folder inside "/templates" with the frankenstyle name of the plugin you want to override. The frankenstyle name looks like: <plugintype>_<pluginname> The plugintype of a subplugin is defined in db/subplugins.json. For the plugins in unilable it is unilabeltype. So, if you want to override the carousel plugin you have to create a folder: unilabeltype_carousel inside <your-theme>/templates' and put the template in there: eg:/templates/unilabeltype_carousel/carousel.mustache` I hope that helps :). Best regards Andreas

VOOM108 commented 3 years ago

Thanks a lot, yes that really helps... :) (For future reference)

For now I had the issue solved by creating the full fade-transition CSS replacing the original classes' CSS :)