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

Generalize navigation object assignment and renderer assignment in block navigation to allow more code reuse in specialization of the block

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.4
    • Component/s: Navigation
    • Labels:
    • Testing Instructions:
      Hide

      These a basic, backend changes. There should be no visible difference.

      1. Without logging in check the navigation block is displayed without errors.
      2. Log in as an administrator.
      3. Use the navigation block a little and just make sure it is still working as expected.
      Show
      These a basic, backend changes. There should be no visible difference. Without logging in check the navigation block is displayed without errors. Log in as an administrator. Use the navigation block a little and just make sure it is still working as expected.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      The global navigation object is generated in the get_content method of the navigation block. This could be extracted to a protected method get_method that could be overridden in specialized navigation block plugins to generate alternate navigation from the global navigation or from scratch. One example is a block to display in a course only the branch of the global navigation that pertains to that course.

          /**
           * Returns the navigation
           *
           * @return navigation_node The navigation object to display
           */
          protected function get_navigation() {
              // Initialise (only actually happens if it hasn't already been done yet
              $this->page->navigation->initialise();
              return clone($this->page->navigation);
          }

      The renderer of the navigation block is fetched by a string

      $renderer = $this->page->get_renderer('block_navigation');

      but could be fetched by reference to the block name

      $renderer = $this->page->get_renderer($this->blockname);

      to allow specialization of the block by redefining the renderer.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                4 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  3/Dec/12