The daily challenge - how to hide the settings dock on the frontpage

The daily challenge - how to hide the settings dock on the frontpage

by Itamar Tzadok -
Number of replies: 2

Hide it from anyone but admin, that is. The point is that while the frontpage is for moodle a front course page, it is also or mainly a front site page. There really rarely is any reason to show the settings block there to anyone but admin who needs it for editing the front page. You can't simply hide it in context because then even admin cannot see it outside editing mode and cannot turn editing on without seeing the block. You can't (or so it seems) hide it by permissions, because there is only one instance of it, and if you prevent access to it by roles it applies site wide.

So I came up with a theme based solution.

In the frontpage sheet of the theme, where the body css classes are calculated and collected, add a condition on $PAGE->user_allowed_editing() and if fails add a class, say, 'hide_settings_block'.

Then add a definition in the theme's core.css (or your theme's equivalent)

body.hide_settings_block .block_settings{display:none;}

That's it. With these tweaks, anyone without editing permissions on the frontpage (almost everyone) will not see the settings block.

Any other techniques to the same effect would be appreciated. smile

Average of ratings: Useful (2)
In reply to Itamar Tzadok

Re: The daily challenge - how to hide the settings dock on the frontpage

by Gerrard Shaw -

Can you elaborate a bit more on this as I need to do exactly the same thing... don't quite get what you mean by the "front page sheet of the theme"

In reply to Gerrard Shaw

Re: The daily challenge - how to hide the settings dock on the frontpage

by Itamar Tzadok -

That's in theme/your-chosen-theme/layout/frontpage.php. Around line 18 there should start a definition of bodyclassess. smile