Reputation: 121
I'd like to find out how or even if it's possible to override the user/preferences elements via Boost theme. Specifically I want to be able to hide aspects of the preferences page, not via CSS. It seems that the blocks are rendered on the user/preferences.php page via the creation of a preferences_group which is then added to the preferences_groups before rendering.
Is it possible to intercept one of these two class constructors?
I do not want to change any of the core Moodle code base, everything must be done via a theme extends/implementation/other.
Current version of Moodle: 4.3.6
Upvotes: 0
Views: 22
Reputation: 121
Not exactly what I was looking for, but this workaround does the job:
The different user/preferences.php sections are render via lib/templates/preferences_groups.mustache template. This mustache template can be overridden through the Boost theme by added a copy of the template to theme/boost/templates/core/preferences_groups.mustache
Once you have this override, you can adjust the HTML code a bit and give each section a unique identifier. By default, these sections have no unique identifiers, which is a bit of an issue for when you want to hide one of them via CSS. I updated this:
<div class="col-md-4">
To this:
<div class="col-md-4" id="preferences_{{title}}">
Which allowed me to be able to hide these sections via CSS.
Now I know, I asked for a non CSS way of hiding these and I'm still looking for one, but for now, this at least allows me to continue with my work.
The answer I was looking for would have been one that would allow me to remove the sections I wanted before it got rendered by the mustache template. Something in the Boost theme that would allow me to intercept the {{#groups}} array being sent to the template before hand, allowing me to add more specific checks, such as user roles, permissions or capabilities.
Upvotes: 0