Is it possible to add custom actions to a version?
-
16-10-2019 - |
문제
I need to add a custom action to versions of a file. Optimally, I want it on the Version History page:
A second best would be the version display form (the result of clicking View on the previous menu):
The users are already working with the version history, and want to easily copy some details from a specific version. I'd like to avoid making them select the version again in my own window.
해결책
The menu is built in JavaScript in the CORE.js file. If you need to add a new menu item, you are going to have to overrides this file... Not cool.
A better approach is to use JavaScript to override the function which creates the menu in Core.js. You will just need to reference your file after the Core.js file and be careful with the defer loading.
About the version display form, the template is defined in DefaultTemplates.ascx
with the id DocLibDisplayFormVersionToolBar
.
I guess you could overrides the default rendering by your own.
다른 팁
I was able to add a menu item as Gilloux suggested in the comment. Here's how it's done, by overriding the method from Core.js:
// keep original version
var original_AddVersionMenuItemsCore;
// override the function from Core.js
function Kobi_AddVersionMenuItemsCore(m, ctx) {
// first, add the original menu items:
original_AddVersionMenuItemsCore(m, ctx);
// add my menu item:
var menuOption = CAMOpt(m, "Add Version to My Project",
"javascript:alert('This one');",
"/_layouts/images/mewa_gotoNamedItems.gif");
menuOption.id = "ID_Kobi_AddVersionToProject";
}
function Kobi_AddVersionActionsOnLoad(){
original_AddVersionMenuItemsCore = AddVersionMenuItemsCore;
AddVersionMenuItemsCore = Kobi_AddVersionMenuItemsCore;
}
// run the method at window load event
_spBodyOnLoadFunctionNames.push("Kobi_AddVersionActionsOnLoad");
Result:
Some help came from Google and these posts: