Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-47559

Add customusermenu theme setting so admins can add items to the new user menu

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.8
    • Fix Version/s: 2.8
    • Component/s: Navigation, Themes
    • Labels:
    • Testing Instructions:
      Hide
      • Navigate to Theme settings (Site administration -> Appearance -> Themes -> Theme settings).
      • Observe that there is a new section for custom user menu items.
      • Create a custom user menu item without specifying an icon, e.g.
        • editmyprofile,moodle|/user/files.php
      • Create a custom user menu item specifying an external image as icon, e.g.
        • editmyprofile,moodle|/user/files.php|https://avatars1.githubusercontent.com/u/1298437?v=2&s=460
      • Create a custom user menu item specifying a pix icon in pix/t form, e.g.
        • editmyprofile,moodle|/user/files.php|addfile
      • Create a custom user menu item with a language string, e.g.
        • editmyprofile,moodle|/user/files.php|addfile
      • Create a custom user menu item with a plaintext string, e.g.
        • Edit mah profile|/user/files.php|addfile
      Show
      Navigate to Theme settings (Site administration -> Appearance -> Themes -> Theme settings). Observe that there is a new section for custom user menu items. Create a custom user menu item without specifying an icon, e.g. editmyprofile,moodle|/user/files.php Create a custom user menu item specifying an external image as icon, e.g. editmyprofile,moodle|/user/files.php|https://avatars1.githubusercontent.com/u/1298437?v=2&s=460 Create a custom user menu item specifying a pix icon in pix/t form, e.g. editmyprofile,moodle|/user/files.php|addfile Create a custom user menu item with a language string, e.g. editmyprofile,moodle|/user/files.php|addfile Create a custom user menu item with a plaintext string, e.g. Edit mah profile|/user/files.php|addfile
    • Affected Branches:
      MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-47559-master

      Description

      The new user menu doesn't have much in it by default. We need to give 2.8 users a good way to add new items without having to resort to code hacks, or forcing them to wait until fancier plugins exist for this simple task.

      A quick method of doing this is to emulate the example of custommenu which has been used for some time.

      A. Add a new text field setting called customusermenu, on the theme settings page, directly under custommenu.

      B. Use this as the default text, it will also function as an example:

      editmyprofile,moodle|/user/edit.php|edit
      messages,message|/message/index.php|message
      myfiles,moodle|/user/files.php|addfile
      mybadges,badges|/badges/mybadges.php|award
      

      People may not want all these, but it's very easy to remove them. I also like to raise awareness of some of these things.

      Rules for customisation text

      Three items divided by pipes |, the third one is optional:

      1. First item is the name of the menu item:
        • if it contains a comma, then get the string from language files as specified
        • otherwise, use the string exactly as it is (don't even clean it)
      2. Second item is a URL. If it starts with / then append it to the wwwroot, otherwise use it exactly as specified. Any %userid% in the text should be replaced with the current $USER->id.
      3. Third item (optional) specifies an icon. First check if the string is a file name in /pix/t and if it is then use it (I think we have some smart mechanism to choose between the png and svg, use it). If that fails then assume it's a plain URL and just use it like that. If there is no third item specified then just fall back to a default icon such as 'user'.

      C. Menu code should look for this setting, parse it and add it after "My home" and before "Log out". The code needs to have good error checking, but any line that fails to parse can just be ignored.

      D. The whole menu can be cached in session to avoid this being done on every page load.

      E. These rules should be documented on https://docs.moodle.org/28/en/Theme_settings

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Nov/14