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

custommenu should allow override by theme

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 2.3
    • Component/s: Themes
    • Labels:
    • Testing Instructions:
      Hide

      can only be tested by someone with ability to modify code.

      in your custom theme settings.php add this (replacing 'theme_afterburner' with the name of your theme = eg 'theme_theloop1' - this displays the custommenu settings on the themes own settings page.

      $name = 'theme_afterburner/custommenuitems';
      $title = get_string('custommenuitems', 'admin');
      $description = get_string('configcustommenuitems', 'admin');
      $default = '';
      $setting = new admin_setting_configtextarea($name, $title, $description, $default);
      $settings->add($setting);

      then in your theme file theme/layout/default.php find this line:

      $custommenu = $OUTPUT->custom_menu();

      and replace it with this:

      $custommenu = $OUTPUT->custom_menu($PAGE->theme->settings->custommenuitems);

      • this tells your theme to use the custommenu defined by the theme instead of using the "global" one.

      then go to your custom themes "settings" page and set up the menu items as you would like - load the theme in your browser and check to see if the custommenu items are set as expected.

      Show
      can only be tested by someone with ability to modify code. in your custom theme settings.php add this (replacing 'theme_afterburner' with the name of your theme = eg 'theme_theloop1' - this displays the custommenu settings on the themes own settings page. $name = 'theme_afterburner/custommenuitems'; $title = get_string('custommenuitems', 'admin'); $description = get_string('configcustommenuitems', 'admin'); $default = ''; $setting = new admin_setting_configtextarea($name, $title, $description, $default); $settings->add($setting); then in your theme file theme/layout/default.php find this line: $custommenu = $OUTPUT->custom_menu(); and replace it with this: $custommenu = $OUTPUT->custom_menu($PAGE->theme->settings->custommenuitems); this tells your theme to use the custommenu defined by the theme instead of using the "global" one. then go to your custom themes "settings" page and set up the menu items as you would like - load the theme in your browser and check to see if the custommenu items are set as expected.
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull Master Branch:
      master_MDL-31043

      Description

      the function custom_menu in outputrenderers.php should allow a different string to be passed so that different themes can set their own custom menus

      here's a possible replacement:
      public function custom_menu($custommenuitems='') {
      global $CFG;
      if (empty($custommenuitems) && !empty($CFG->custommenuitems))

      { $custommenuitems = $CFG->custommenuitems; }

      if (empty($custommenuitems))

      { return ''; }

      $custommenu = new custom_menu($custommenuitems, current_language());
      return $this->render_custom_menu($custommenu);
      }

      this means that in a themes default.php we could do something like this:
      $custommenu = $OUTPUT->custom_menu($PAGE->theme->settings->custommenuitems);

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  25/Jun/12