php - Moodle 2.7 Need to know how to create custom menu for different user groups -



php - Moodle 2.7 Need to know how to create custom menu for different user groups -

i have been working on moodle 2.7 framework, requirement wanted show 2 different custom menu teacher , pupil role, @ nowadays have created custom menu in template options, have no thought how create multiple custom menu in moodle. far tried doing searching grouping id , utilize if statement assign custom menu still no output, request can help me sort issues.

you can extend custom menu - https://docs.moodle.org/dev/extending_the_theme_custom_menu

then utilize has_capability() see if user can see menu item.

something (i haven't tried it)

// theme/themename/renderers.php class theme_themename_core_renderer extends core_renderer { protected function render_custom_menu(custom_menu $menu) { $context = context_system::instance(); if (has_capability('local_plugin/menuname:view', $context)) { $branchlabel = get_string('menuname', 'local_myplugin'); $branchurl = new moodle_url('/local/myplugin/index.php'); $branchtitle = $branchlabel; $branchsort = 10000; $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort); } homecoming parent::render_custom_menu($menu); } }

php moodle

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -