Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to add a custom action to versions of a file. Optimally, I want it on the Version History page:

enter image description here

A second best would be the version display form (the result of clicking View on the previous menu):

enter image description here

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
Thanks! but Yack! I'd like something that's less likely to destroy the whole farm - I only need it in a few sites, so a site feature with custom actions seems more natural. Interesting, though, I guess that could work... –  Kobi Jun 21 '11 at 12:35
1  
these kind of changes won't destroy anything but yes would be "farm scoped". You could use javascript overrides by overriding the javascript function which creates the menu. You will just need to reference your file after the Core.js file and be careful with the defer loading –  GillouX Jun 21 '11 at 12:38
    
Oh, I'm just being over-dramatic with "destroy" :) –  Kobi Jun 21 '11 at 12:40
    
I'm accepting this answer for the comment you've posted, it led my in the right direction. I was able to get it working, in what I consider an elegant solution, in just under an hour. Thanks! –  Kobi Jun 26 '11 at 10:43

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:
enter image description here

Some help came from Google and these posts:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.