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

Custom-coded menu not displayed when custommenuitems is empty

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a bug
    • Affects Version/s: 2.6.4
    • Fix Version/s: None
    • Component/s: Navigation, Themes
    • Labels:
      None
    • Affected Branches:
      MOODLE_26_STABLE

      Description

      RECREATE

      In a custom theme renderers.php, override render_custom_menu() and add some hard-coded menu item. e.g:

      <?php
      class theme_zebra_core_renderer extends core_renderer {
        protected function render_custom_menu(custom_menu $menu) {
          $menu->add('Home', new moodle_url('/'));
          return parent::render_custom_menu($menu);
        }
      }
      

      Browse to /admin/settings.php?section=themesettings and configure custommenuitems to be blank (no spaces, no new lines). Save.

      EXPECTED RESULTS

      The Home menu item will be displayed.

      ACTUAL RESULTS

      No custom menu items are displayed

      CODE

      The culprit for this unexpected behavior occurs in lib/outputrenderers.php in function custom_menu:

              if (empty($custommenuitems)) {
                  return '';
              }
      

      By returning an empty string when the configured $custommenuitems is blank, the overridden render_custom_menu() is never executed

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              pjking07 PJ King
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta, Bas Brands, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: