views:

36

answers:

1

Hi,

I was wondering if someone could help me out with Sharepoint 2007. What I want to do is to add a custom menu item to a context menu (the menu that opens when you click a document or another item).

Right now, the menu looks like this: picture

I want to add an item, "Do stuff" for example, to this menu. Major problems:

  1. I wish this item to appear only in menus for a certain file type (e.g. only for .html but not for .doc);
  2. When I click this item ("Do stuff"), I want to call custom external code (written in C#, either an exe or a DLL), which accepts the name of the clicked file as an input parameter.

I understand the way to achieve this is by using Custom Actions (no javascript editing required in 2007, right?). But since I'm quite new to MOSS, I'm a bit lost and not sure what exactly to do and where to start, so any help is greatly appreciated.

+1  A: 

Hi w500

You have to implement a CustomAction like this:

<CustomAction
   Id="YourUniqueId"
   Location="EditControlBlock"
   RegistrationType="FileType"
   RegistrationId="html"
   Sequence="20"
   Title="The text you want">
  <UrlAction Url="~site/_layouts/company/ActionPage.aspx?List={ListId}&amp;ID={ItemId}" />
</CustomAction>

What you put in the Url of UrlAction depends on what you want to do. It can be JavaScript or the url of a Page or Handler.

In my example it's a Page which gets the QueryParameters so that SPContext.Current.ListItem will contain the selected documents listitem.

Per Jakobsen
Per,thanks for quick reply. One thing I'm unsure of is where exactly do I put this xml file? Somewhere in the ...\TEMPLATE\FEATURES perhaps?Is there a specific way to obtain an Id value, or do I just make one up?
The best start for working with Features is the MSDN article: Create a Simple Feature http://msdn.microsoft.com/en-us/library/ms475286(v=office.12).aspx
Per Jakobsen
Yes, create a new feature which has a pointer to an elements file. In the elements file, put this CustomAction xml and create a unique ID for each CustomAction you wish to create.
desigeek