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

From MoodleDocs
Revision as of 19:03, 21 May 2009 by Alan Trick (talk | contribs) (put caption in line with image)
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).

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 for the bug).

Outline does not show

The outline is turned off by default, see 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 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 showgrades setting is turned on in the course. On by default.
Participants
Only available if the user has the moodle/course:viewparticipants capability. On by default.

Adding new items

The code that generates this is in the available_items function of block_yui_menu.php. 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
A string. The text inside the label. This is usually contains a call to the get_string function for localisation.
url
A string. Where the item points to. This is not a fully qualified URL, it is automatically prefixed with $CFG->wwwroot.
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.

  1. The top-level icons for each item is set in the available_items function (see the above section).
  2. Most of the other icons are set in the styles.php css file. Some things like the + and - 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.
  3. The resources are a bit funny. A resource is an activity module, and it will get the default resource icon set in styles.php 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 _yui_menu_icon near the end of the course_section function in block_yui_menu.php. The actual setting of the background image is done elsewhere.

External Links