Hello.
I believe we already found the solution. Let me post it here for other users.
First thing you need to do is to add a new MenuItem button. You can do so in the
ReloadMenu method (~\CMSModules\Content\Controls\EditMenu.ascx.cs) which I suppose you have done already.
It is worth to mention the JavascriptCommand property that should contain a name of your custom javascript method:
newItem2.JavascriptCommand = FunctionsPrefix + "RejectToEdit(" + nodeId + ");";
This method should be defined in the
~\CMSModules\Content\CMSDesk\Edit\EditMenu.js file:
function RejectToEdit(nodeId) {
if ((parent.frames[controlFrame] != null) && (parent.frames[controlFrame].RejectToEdit != null)) {
parent.frames[controlFrame].RejectToEdit(nodeId);
}
}
As you can see, another javascript method from the parent frame called RejectToEdit(nodeId) is called. This time, you need to define it in the following file:
~\CMSScripts\cmsedit.jsfunction RejectToEdit(nodeId) {
ClearToolbar();
if (window.frames['pageview'].RejectToEdit) {
window.frames['pageview'].RejectToEdit(nodeId);
}
}
At this point, you need to go to the
~\CMSModules\Content\CMSDesk\Edit\Edit.aspx.cs file and add a new button to the aspx markup:
<cms:CMSButton ID="btnRejectToEdit" runat="server" CssClass="HiddenButton" EnableViewState="false" OnClick="btnRejectToEdit_Click" />
This button will be hidden due to the assigned CssClass. In the code behind, you need to define the OnClick method that gets executed when the button has been clicked:
protected void btnRejectToEdit_Click(object sender, EventArgs e)
{
// Here goes your custom code
}
And now, last but not least, you need modify the OnInit method in the same file. At the end of the OnInit method, you can see the following code that registers another javascript methods that are required to fire OnClick handlers of the buttons (Save, Reject, etc.):
AddScript(
"function SaveDocument(nodeId, createAnother) { document.getElementById('hidAnother').value = createAnother; " + (confirmChanges ? "AllowSubmit(); " : "") + ClientScript.GetPostBackEventReference(btnSave, null) + "; } \n" +
"function Approve(nodeId) { SubmitAction(); " + ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" +
"function Reject(nodeId) { SubmitAction(); " + ClientScript.GetPostBackEventReference(btnReject, null) + "; } \n" +
"function CheckIn(nodeId) { SubmitAction(); " + ClientScript.GetPostBackEventReference(btnCheckIn, null) + "; } \n" +
(confirmChanges ? "var confirmLeave='" + GetString("Content.ConfirmLeave") + "'; \n" : "")
);
You need to simply add a reference to your custom javascript RejectToEdit method and create a post back reference to your custom button btnRejectToEdit as demonstrated here:
"function RejectToEdit(nodeId){ SubmitAction(); " + ClientScript.GetPostBackEventReference(btnRejectToEdit, null) + "; } \n"
Best Regards,
Radek Macalik