Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: YUI menu.

YUI menu: Difference between revisions

From MoodleDocs
(furture development)
(→‎Future Development: the future is now!)
 
(3 intermediate revisions by the same user not shown)
Line 31: Line 31:
If you have installed installed the block and the installation went fine, you should be able to find it under ''Modules > Blocks > Manage blocks'' in the site administration menu. The one caveat is that its name (at the moment) is “Course Menu” not “YUI menu” as you might expect. You should also be able to go into a course page and add the block there (it will be also called “Course Menu” there).
If you have installed installed the block and the installation went fine, you should be able to find it under ''Modules > Blocks > Manage blocks'' in the site administration menu. The one caveat is that its name (at the moment) is “Course Menu” not “YUI menu” as you might expect. You should also be able to go into a course page and add the block there (it will be also called “Course Menu” there).


=== Error on page (Javascript) ===
=== Old Problems ===
 
Using the latest version of the YUI menu should solve all of these.
 
==== Error on page (Javascript) ====


The YUI menu depends directly on the YUI library in Moodle. Moodle 1.9.3 upgraded from YUI 2.4 to 2.6. Unfortunately, YUI broke backwards compatibility in this release. Early versions of the YUI menu won’t work with Moodle 1.9.4 or later. If you have this problem, update to the latest version of the YUI menu.
The YUI menu depends directly on the YUI library in Moodle. Moodle 1.9.3 upgraded from YUI 2.4 to 2.6. Unfortunately, YUI broke backwards compatibility in this release. Early versions of the YUI menu won’t work with Moodle 1.9.4 or later. If you have this problem, update to the latest version of the YUI menu.


=== Outline is messed up and +/- icons not showing ===
==== Outline is messed up and +/- icons not showing ====


In the same update, the YUI developers managed to royally mess up their style files, essentially breaking the menu. Either manually downgrade to YUI 2.4 or upgrade to Moodle 1.9.4 (the Moodle developers have provided a [http://tracker.moodle.org/browse/MDL-17218 workaround] for the bug).
In the same update, the YUI developers managed to royally mess up their style files, essentially breaking the menu. Either manually downgrade to YUI 2.4 or upgrade to Moodle 1.9.4 (the Moodle developers have provided a workaround (MDL-17218) for the bug).


=== Outline does not show ===
==== Outline does not show ====


The outline is turned off by default, see [[#Customisation|Customisation]].
The outline used to be turned off by default.


== Customisation ==
== Customisation ==


The YUI menu blocks can be customised individually. To do this turn editing on, and an edit button should appear under the title of
The YUI menu blocks can be customised individually or globally. To edit it individually, go to the course that it is in and turn editing on, and an edit button should appear under the title of the block. This customisation allows the available menu items to be moved around and either hidden or shown.
the block. This customisation allows the available menu items to be moved around and either hidden or shown.
 
By default, the available menu items are comprised of module links and other pre-set items. The module links are created based on which activity modules are in the course. For example, a course with a news forum will have an item for forums. There are five pre-set items:
 
;Outline
:Off by default. This is where the YUI code is used place. Creates a collapsible tree of the course content.
;Messages
:Off by default. A link to the Moodle messages page.
;Calendar
:Off by default. The course calendar page;
;Gradebook
:Only available if the <code>showgrades</code> setting is turned on in the course. On by default.
;Participants
:Only available if the user has the <code>moodle/course:viewparticipants</code> capability. On by default.
 
=== Adding new items ===
 
The code that generates this is in the <code>available_items</code> function of <code>block_yui_menu.php</code>. They are structured in an array. Each item is an entry, the key defines the item’s name which must be unique, but is otherwise insignificant. The value is another array which contains the following:


;text
To edit it globally, go to the admin page and it should should up in the menu (under blocks). You can enable and disable menu plugins there as well as set their default ordering. It is also possible to write your own plugins. Look at the other plugins as a reference.
:A string. The text inside the label. This is usually contains a call to the <code>get_string</code> function for localisation.
;url
:A string. Where the item points to. This is not a fully qualified URL, it is automatically prefixed with <code>$CFG->wwwroot</code>.
;icon
:A string. The URL for the icon, unlike '''url''' this actual isn’t prefixed with anything and should contain the full path.
;default
:A boolean. Whether or not the item is displayed by default on unconfigured menus.
;title
: An optional string. Will put a tooltip on the item with the given text.
 
=== Icons ===
 
The icons that are used come from 3 different sources.
 
# The top-level icons for each item is set in the <code>available_items</code> function (see the above section).
# Most of the other icons are set in the <code>styles.php</code> css file. Some things like the <code>+</code> and <code>-</code> icons for the menu come from YUI. Other parts, like the icons for the section nodes and individual modules are pulled from standard Moodle icons.
# The resources are a bit funny. A resource is an activity module, and it will get the default resource icon set in <code>styles.php</code> like the other activities. However, a resource can specify an icon that overrides this. Because this is done on an individual basis, so it needs to be done when the javascript code creates that tree item. The end result is that the icons for each resource is overridden by setting the the <code>_yui_menu_icon</code> near the end of the <code>course_section</code> function in <code>block_yui_menu.php</code>. The actual setting of the background image is done elsewhere.


== Future Development ==
== Future Development ==


The following enhancements are in the works and will hopefully be done by the end of the summer.
There are no more plans to migrate the YUI menu to Moodle 2.0. Instead, it will be replaced by a similar block that will become part of the Moodle core. A migration plan should be developed.
 
* A plug-in system for each of the list items. This will make the code neater and also make it easier to add and remove items
* A configuration system for the plug-ins
* Moodle 2.0 compatibility


== External Links ==
== External Links ==

Latest revision as of 23:36, 8 June 2009

YUI Menu.png
The menu in Moodle 1.9
TypeBlock
DownloadLatest version
Source CodeCVS
Bug TrackerMoodle Tracker
LicenseGPL 3 or greater

The YUI menu is a course menu is inspired by the Course Menu+ from NetSapiensis.com as well as the one from Humbolt State University. It is freely available under the GPL 3.

Here’s how it’s different:

  • It uses the built-in YUI javascript libraries so it’s much smaller
  • It works fine, even on the highest error reporting levels.
  • It is XHTML compatible.
  • It’s easier to add new sorts of menu items (although not as easy as it should be).
  • The ‘Chapters’ and ‘Control Panel’ have been dropped because they added unnecessary complexity or belonged in a separate module.

Installation

Install this block in the standard way. Unpack it into the blocks/ directory. Then go to Moodle’s admin page and it will install itself.

Troubleshooting

For various reasons, you may have trouble installing this module. Here are a list of questions which have been raised in the discussion forums.

Unable to find block after installation

If you have installed installed the block and the installation went fine, you should be able to find it under Modules > Blocks > Manage blocks in the site administration menu. The one caveat is that its name (at the moment) is “Course Menu” not “YUI menu” as you might expect. You should also be able to go into a course page and add the block there (it will be also called “Course Menu” there).

Old Problems

Using the latest version of the YUI menu should solve all of these.

Error on page (Javascript)

The YUI menu depends directly on the YUI library in Moodle. Moodle 1.9.3 upgraded from YUI 2.4 to 2.6. Unfortunately, YUI broke backwards compatibility in this release. Early versions of the YUI menu won’t work with Moodle 1.9.4 or later. If you have this problem, update to the latest version of the YUI menu.

Outline is messed up and +/- icons not showing

In the same update, the YUI developers managed to royally mess up their style files, essentially breaking the menu. Either manually downgrade to YUI 2.4 or upgrade to Moodle 1.9.4 (the Moodle developers have provided a workaround (MDL-17218) for the bug).

Outline does not show

The outline used to be turned off by default.

Customisation

The YUI menu blocks can be customised individually or globally. To edit it individually, go to the course that it is in and turn editing on, and an edit button should appear under the title of the block. This customisation allows the available menu items to be moved around and either hidden or shown.

To edit it globally, go to the admin page and it should should up in the menu (under blocks). You can enable and disable menu plugins there as well as set their default ordering. It is also possible to write your own plugins. Look at the other plugins as a reference.

Future Development

There are no more plans to migrate the YUI menu to Moodle 2.0. Instead, it will be replaced by a similar block that will become part of the Moodle core. A migration plan should be developed.

External Links