Auto dock all side blocks in Moodle

While searching on the internet, I came up to a solution to dock all the side blocks on your Moodle site by default which I thought to share with all of my readers as it is a very handy and useful tip. Thanks to Jaswant Tak, for sharing such a nice tip through his blog.

So, coming back to the point, to hide all the side blocks on your Moodle site you need to change one of the core files of Moodle, which is not recommended. If you still wants to continue with it then please keep a track of all the changes in core Moodle files before upgrading your Moodle site to a new version.

  • Open the file your_moodle_site/blocks/moodleblock.class.php in any text editor like Notepad++.
  • Find the function html_attributes (In my case it is on line number 411)
  • Change the line having the code:

if ($this->instance_can_be_docked() && get_user_preferences(‘docked_block_instance_’.$this->instance->id,0)) {


if ($this->instance_can_be_docked() && get_user_preferences(‘docked_block_instance_’.$this->instance->id,1)) {

(in my case it is line number 420)

  • Save changes.

This will dock all the side blocks except for the admin user.

If you want to skip any particular block from docking  then you can use the negated && (AND) condition in the statement as follows:

Let’s say you don’t want to dock the “Login” block then change the same line with this code:

if ($this->instance_can_be_docked() && get_user_preferences(‘docked_block_instance_’.$this->instance->id, 1) && $this->name() != ‘login’) {

And save changes.

Docked Blocks
All side blocks are docked by default

Thanks Jaswant Tak for sharing such a nice tips with whole Moodle community.


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