Creating different custom menu bars for different courses: Creating different menu bars: Difference between revisions
(Created page with "{{Template:Themes}}This tutorials explains how to create different custom menu bars for different courses in a Moodle site This tutorial involves some previous knowledge of p...") |
|||
Line 3: | Line 3: | ||
This tutorial involves some previous knowledge of php and css. The level of difficulty of the tutorial is moderate. | This tutorial involves some previous knowledge of php and css. The level of difficulty of the tutorial is moderate. | ||
== | ==What is the 'custom menu' bar== | ||
Number list | |||
# | |||
# | |||
## | |||
## | |||
I | |||
Link to other pages | |||
* [[Themes 2.0 creating your first theme]] | * [[Themes 2.0 creating your first theme]] | ||
* [[Themes 2.0 overriding a renderer]] | * [[Themes 2.0 overriding a renderer]] | ||
==Getting started== | ==Getting started== |
Revision as of 13:40, 2 August 2013
This tutorials explains how to create different custom menu bars for different courses in a Moodle site
This tutorial involves some previous knowledge of php and css. The level of difficulty of the tutorial is moderate.
Number list
I
Link to other pages
Getting started
Alright, as you have already have your theme ready to go preparation is pretty simple, we are going to go through and create (if you haven't already) the following files:
- theme/themename/lib.php
- theme/themename/renderers.php
- theme/themename/lang/en/themename.php
Next step open up your themes config.php file and add the following configuration option to it (at the bottom):
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
If you've already got a custom renderer you will already have this line.
And thats it! now we move on to extending the custom menu.
Adding the My Courses branch
So the point of this extension is to add a My Courses branch to the end of the custom menu.
The plan is to have the my courses branch and then within that branch have an entry for every course the user is enrolled in, much the same as the my courses branch of the navigation.
In order to achieve this we need to add some items to the custom menu, the my courses branch and all of the courses within it. We can do this overriding the core_renderers render_custom_menu method, of more accuratly create our own render_custom_menu method that adds our items and then calls the original. Remember we only need to add items, we don't need to change what is being produced.
So within our renderers.php file add the following code:
class theme_themename_core_renderer extends core_renderer {
protected function render_custom_menu(custom_menu $menu) {
// Our code will go here shortly
}
}