Development:Moodle 2.0 navigation how to: Difference between revisions
Sam Hemelryk (talk | contribs) No edit summary |
Sam Hemelryk (talk | contribs) |
||
Line 4: | Line 4: | ||
==What the navigation is== | ==What the navigation is== | ||
It's very important to understand what the navigation is exactly within Moodle 2.0. One of the numerous goals for Moodle 2.0 was to standardise navigation throughout Moodle and try to bring order to the structure of a Moodle site. | |||
The solution to this was of course the navigation. Don't think about the navigation or settings blocks those are just interpretations of the navigation structure Moodle creates. The navigation structure is what you really need to understand. | |||
For those of you who have already started looking into either writing code for Moodle 2.0 or converting some existing code you will have undoubtedly come across the page object '''$PAGE''' against which you set the heading for the page, the title, any JavaScript requirements, and a whole lot of other stuff that is used by the page. | |||
The navigation structure within Moodle uses the information $PAGE contains to generate a navigation structure for the site that reflects the page that the user is viewing. | |||
This navigation structure is the available through three variables the can be interacted with the alter the navigation, but more about that later. | |||
The three variables are: | |||
; $PAGE->navigation : This is the main navigation structure, it will contain items that will allow the user to browse to the other important pages that are available to them. | |||
; $PAGE->settingsnav : This is the settings navigation structure, it will contain items that will allow the user to edit different things for whatever they are viewing. | |||
; $PAGE->navbar : The navbar is a special structure, it is essentially the active item in the navigation preceded by all of its parents plus anything the page wants to add. | |||
The above is a basic overview of the navigation structures which the following sections will attempt to explain in more detail. So onto what the navigation is not. | |||
==What the navigation isn't== | ==What the navigation isn't== |
Revision as of 01:22, 28 June 2010
Please do not edit it until this notice has been removed.
This document looks at the navigation within Moodle 2.0 from a development perspective. It aims to outline what the navigation is, how it works, how to add to it, how to hack it, and how to debug it. If you're writing a plugin, or some arbitrary code and want to make the navigation meet your needs to complete the look of what ever you are working on then this is the document for you. If you're not a PHP developer you're certainly in the wrong place.
It's very important to understand what the navigation is exactly within Moodle 2.0. One of the numerous goals for Moodle 2.0 was to standardise navigation throughout Moodle and try to bring order to the structure of a Moodle site.
The solution to this was of course the navigation. Don't think about the navigation or settings blocks those are just interpretations of the navigation structure Moodle creates. The navigation structure is what you really need to understand.
For those of you who have already started looking into either writing code for Moodle 2.0 or converting some existing code you will have undoubtedly come across the page object $PAGE against which you set the heading for the page, the title, any JavaScript requirements, and a whole lot of other stuff that is used by the page.
The navigation structure within Moodle uses the information $PAGE contains to generate a navigation structure for the site that reflects the page that the user is viewing.
This navigation structure is the available through three variables the can be interacted with the alter the navigation, but more about that later. The three variables are:
- $PAGE->navigation
- This is the main navigation structure, it will contain items that will allow the user to browse to the other important pages that are available to them.
- $PAGE->settingsnav
- This is the settings navigation structure, it will contain items that will allow the user to edit different things for whatever they are viewing.
- $PAGE->navbar
- The navbar is a special structure, it is essentially the active item in the navigation preceded by all of its parents plus anything the page wants to add.
The above is a basic overview of the navigation structures which the following sections will attempt to explain in more detail. So onto what the navigation is not.
A fish
It doesn't... does it?
You can't unless your code fu is strong
Through module callbacks
Why would you want to, its perfect just as it is.