I love a challenge so this is how I approached the issue.
Just to get a visual understanding of what was being asked, here is the before and after of the bottom navigation menu in Moodle.
Notice 2 important parts to this. The icon uses font awesome (so you must have font awesome installed or replace the icon with the word Home) and the extra long name for the next page is wrapped around to stop it overlapping with the home button.
So how do we do this?
First we create a custom HTML Block, I will call it Course Messages, that is set to appear on every page of our course. Remember this is based on a single course, not as a global function, because we don’t have access to the main theme or to the administration tools.
Now that we have this block, we can add some custom code to it.
With editing turned on, select ‘configure Course Message Block’.
You can now add some code.
There are two key pieces of information we need.
- To find the location in the page that the Home button needs to be added to.
- The URL that will take someone to the course home page.
By looking through the HTML I found the bottom navigation drop down menu has a class called urlselect. Using this class I can add the HTML href elements before the drop down list.
The second item to find is the URL to go to the Home page for this course.
By looking in the Breadcrumbs, we can find the course URL. Notice it will be the 4th item in the breadcrumbs.
The complete code below shows how the menu item was created.
Line 13: Finds the breadcrumb-items on your page because we need the URL from the course href to attach to the home button (I had no other way to get the course URL)
Line 14: Grabs the fourth breadcrumb-item which is the course link. (Being zero based the items are number 0,1,2,3,4. So the 4th breadcrumb is actually item number 3)
Line 15: Extract the href value to use later for the home button. (We now have the home button url)
Line 16: Create a new A DOM element to add the href to.
Line 17: Add the href attribute to the new A element.
Line 18: Add some HTML including a font awesome class inside the href so that the user has something to click on.
Line 19: Get the urlselect element
Line 20: Insert the new A href link and font awesome HTML into the urlselect element.
And that’s it.
Obviously if you wanted to apply this globally, you would use a theme and have the admin update the theme.
Preferably you would use a child theme so that you can update your master theme without causing custom code issues, but that is another story.
Let me know if you need any help…