Moodle 4 extend navigation

Moodle 4 extend navigation

ដោយ Thomas Kroh នៅ
ចំនួនតប៖ 8

Hello,

we plan a relaunch of our Moodle with the latest version.

I wrote a small plugin to extend the navigation (I want to hide the menu item "My courses", the hook  "local_<pluginname>_extend_navigation(global_navigation $navigation)" gets called.

This is a snippet from my plugin:

if ($item = $navigation->find("mycourses", global_navigation::TYPE_ROOTNODE)) {
        $item->remove();
 }

I tried different versions, also with $item->showinflatnavigation = false. But I don't get it right. The "My courses" menu item still appears. In our older Moodle System (3.5) this was the way it worked.
Were there any changes in Moodle 4?  For any help I would be very grateful!

Thanks a lot!

មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Thomas Kroh

Re: Moodle 4 extend navigation

ដោយ Renaat Debleu នៅ
រូបភាព Core developers រូបភាព Particularly helpful Moodlers រូបភាព Plugin developers
Have a look at how they do it in the local_boostnavigation plugin.
 
មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Renaat Debleu

Re: Moodle 4 extend navigation

ដោយ Thomas Kroh នៅ
Thanks a lot for your answer. I have tried your theme but my Moodle Installation did not recognize it. I made a git pull in the Moodle theme directory. Could this be a problem in the settings.php or config.php (version problem?). Moodle does not show any update information what is usually displayed if a new plugin or theme was installed on the server.
មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Renaat Debleu

Re: Moodle 4 extend navigation

ដោយ Thomas Kroh នៅ
It was my mistake, now the new theme settings are available. But the "My Courses" Item still is shown. Also I can't hide any other menu item through this theme enhancement (for example the Home Menu Item). 

ឯកសារភ្ជាប់ boost settings.png
មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Renaat Debleu

Re: Moodle 4 extend navigation

ដោយ Thomas Kroh នៅ
Ok, I have found an issue on Github:
https://github.com/moodle-an-hochschulen/moodle-local_boostnavigation/issues/112

This extension does not work with Moodle 4 anymore. It seems there were any changes in Moodle?
មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Thomas Kroh

Re: Moodle 4 extend navigation

ដោយ Gemma Lesterhuis នៅ
រូបភាព Particularly helpful Moodlers រូបភាព Plugin developers រូបភាព Testers
Thomas,
You can hide the menu item by adding custom css to your theme.

.primary-navigation li[data-key="courses"] {

display: none;

}

Gem
មធ្យមភាគនៃរង្វាយតម្លៃ:Useful (2)
ឆ្លើយតបទៅកាន់ Gemma Lesterhuis

Re: Moodle 4 extend navigation

ដោយ Thomas Kroh នៅ
Hi Gem,

I thank you soooo much, that did the job ញញឹម Perhaps I find some time to study the navigationlib and find out what changed in the API and why the custom hooks don't work anymore like before.
Have a nice day!

all the best from Salzburg / Austria,
Tom
មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Thomas Kroh

Re: Moodle 4 extend navigation

ដោយ Tyler Bannister នៅ
រូបភាព Core developers រូបភាព Plugin developers

It looks like the custom hooks don't work in Boost because they are not used (at all) for the top menu.  The navigation block was deemed unnecessary, but none of that functionality was moved to the new top menu.  It doesn't use the navigation object to render the top navigation.  The new top menu is only the three hard coded links and whatever is specified in the theme settings for "custommenuitems".

The old hooks should continue to work in classic, but they seem to have no effect on the primary navigation in Moodle 4.

មធ្យមភាគនៃរង្វាយតម្លៃ:Useful (1)
ឆ្លើយតបទៅកាន់ Thomas Kroh

Re: Moodle 4 extend navigation

ដោយ Mark Sharp នៅ
រូបភាព Core developers រូបភាព Particularly helpful Moodlers រូបភាព Plugin developers

In your theme's config.php, there is a new setting you can apply: $THEME->removedprimarynavitems

You just need to provide a list of items you want removed (as an array). And these options are: home, myhome, courses, siteadmin

If you wanted to remove "My courses" then you'd have:

$THEME->removedprimarynavitems = ['courses'];
មធ្យមភាគនៃរង្វាយតម្លៃ:Useful (6)