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

Navigation customisation within plugins should use 'navigation' namespace

    XMLWordPrintable

Details

    • MOODLE_400_STABLE
    • MOODLE_401_STABLE
    • MDL-74733-master
    • Hide
      1. On a test course, you will need one of each of the following activity types: assign, feedback, glossary, label, quiz. These can be created with all default options; you don't need any content.
      2. Go into each activity type (for the label it doesn't have its own page, but you can go to the settings page for it).
      3. CHECK there are no errors or warnings.
      4. Go into the 'Feedback' activity, using a large window so that it has the full space available, and look at the secondary navigation.
      5. CHECK the 'Responses' link is one of the top-level options (this is testing that the custom navigation works; without it, this link ends up in the More menu).
      6. You will also need an HTML block (if you don't already have one, go to blocks, add a block, and choose 'Text').
      7. Click the 'Configure' icon in the block header.
      8. CHECK the settings form appears with no errors or warnings. There is no secondary navigation on this page.
      Show
      On a test course, you will need one of each of the following activity types: assign, feedback, glossary, label, quiz. These can be created with all default options; you don't need any content. Go into each activity type (for the label it doesn't have its own page, but you can go to the settings page for it). CHECK there are no errors or warnings. Go into the 'Feedback' activity, using a large window so that it has the full space available, and look at the secondary navigation. CHECK the 'Responses' link is one of the top-level options (this is testing that the custom navigation works; without it, this link ends up in the More menu). You will also need an HTML block (if you don't already have one, go to blocks, add a block, and choose 'Text'). Click the 'Configure' icon in the block header. CHECK the settings form appears with no errors or warnings. There is no secondary navigation on this page.

    Description

      When customising navigation within a plugin, you need to add a class:

      mod_yourplugin\local\views\secondary

      (The code that does this is in pagelib.php function magic_get_secondarynav and also in blocklib.php get_secondarynav.)

      This namespace is not really correct in my opinion, although the definition in https://docs.moodle.org/dev/Coding_style#Rules_for_level2 is not as clear as it could be. My understanding, though, is that:

      • mod_yourplugin\local is reserved for custom namespaces that are used/defined only within the current plugin (i.e. for the plugin to organise its own code)
      • Code that is used for integrating with core features or APIs should use mod_yourplugin\apiname.

      In this case 'navigation' is a core API (see https://moodle.github.io/devdocs/docs/apis) so it should be used in this namespace:

      mod_yourplugin\navigation\views\secondary

      To fix it without losing backward compatibility, I would suggest that the magic function above should look in the 'navigation' namespace first and then the 'local' one.

      We should also move all the existing uses of this class in core modules.

      Attachments

        1. Step 3_Assignment.PNG
          Step 3_Assignment.PNG
          51 kB
        2. Step 3_Feedback.PNG
          Step 3_Feedback.PNG
          45 kB
        3. Step 3_Glosarry.PNG
          Step 3_Glosarry.PNG
          47 kB
        4. Step 3_Label.PNG
          Step 3_Label.PNG
          41 kB
        5. Step 3_Quiz.PNG
          Step 3_Quiz.PNG
          41 kB
        6. Step 5.PNG
          Step 5.PNG
          46 kB
        7. Step 8.PNG
          Step 8.PNG
          41 kB

        Issue Links

          Activity

            People

              quen Sam Marshall
              quen Sam Marshall
              Mike Churchward Mike Churchward
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Gladys Basiana Gladys Basiana
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski
              Votes:
              5 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                14/Nov/22

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 5 minutes
                  2h 5m