I never figured out how to do this in code or XML, but I got it in JavaScript.
I added the following code to AllItems.aspx:
<script type="text/javascript">
function Custom_AddDocLibMenuItems(m, ctx) {
var otype = currentItemFSObjType = GetAttributeFromItemTable(itemTable, "OType", "FSObjType");
if (otype != 1) {
var itemId = GetAttributeFromItemTable(itemTable, "ItemId", "Id");
var listId = ctx.listName;
var action = 'Go_To_Page("' + ctx.HttpRoot + '/_layouts/MyPage.aspx?ListId=' + listId + '&ListItemID=' + itemId + '");';
var option = CAMOpt(m, 'Do Something', action, '/_layouts/IMAGES/10.gif', '', 1110);
option.id = "ID_Do_Something";
}
return false;
}
function Go_To_Page(page) {
window.location = page;
}
</script>
One unfortunate side effect is the item is always first in the context menu.
source
share