-
Improvement
-
Resolution: Won't Do
-
Minor
-
None
-
Future Dev
When editing a course from the course index, each activity includes an "Edit" dropdown menu:
This menu is available to:
- users with the moodle/course:manageactivities capability
- who are viewing the course index
- with Editing mode enabled
This menu is static - that is its content cannot be changed programatically between activities.
This issue proposes to allow individual activities to add to and extend the menu to add new actions, for example:
In this screenshould you can see highlighted a new customized action menu link. In this case the activity module developer can add action menu link targeting all to the view all course modules page.
To replicate:
- cherry pick this commit into your moodle codebase: https://github.com/ScottVerbeek/moodle/commit/6adff874efbd8e3f146d549ef9487a635413847d
- then add this callback to your module:
/**
|
* Callback to add addition action menu item.
|
*
|
* @param int $cmid The course module id.
|
* @return array Array of action_menu_link_secondary.
|
*/
|
function modulename_extend_action_menu($cmid) { |
global $COURSE; |
|
$actions = array(); |
|
$actions['custom1'] = new action_menu_link_secondary( |
new moodle_url('/mod/modulename/index.php', array('id' => $COURSE->id)), |
new pix_icon('a/view_list_active', '', 'moodle', array('class' => 'iconsmall')), |
get_string('viewall', 'mod_modulename'), |
array('class' => 'editing_delete', 'data-action' => 'hello') |
);
|
return $actions; |
}
|
Expected is that you would get a extra action menu link in the "Edit" drop down. I've created a sample plugin here: https://github.com/ScottVerbeek/moodle-mod_extendedactionmenu You can install this plugin and create one in the modules to achieve the result as shown in attached screenshot.
If the callback is not programmed properly it will throw a moodle coding exceptions;
- If the callback doesn't return a array; or
- elements of the array which the callback returned are not of type action_menu_link_secondary.
For this to be as little disruptive of current user experience, I've find that the placement of custom actions at the bottom of the list, but before the delete action, is best.
Prototype Link: https://github.com/ScottVerbeek/moodle/commit/a046b7b592fb558face4846834ea5fa01c197c4a
Also a mock module which implements the callback: https://github.com/ScottVerbeek/moodle-mod_extendedactionmenu/commit/c8954d6713ccd186223b7572b8fdf991a1458d15
- has been marked as being related by
-
MDL-75366 Allow blocks to add custom action menu links on modules and sections
-
- Open
-