How to create your own custom menu/item/actions in Sharepoint?

Often times we have to customise SharePoint’s stock user interface, particularly elements such as edit block, toolbar, menus, etc. It’s possible to have our own custom items in these areas, but first it would be a lot easier to understand their names and locations respectively. These are some of the common locations we will customize:

  • Custom Menu 
    • You can add custom menu item under the New action block.
    • Sharepoint custom menu
  • Custom Toolbar 
    • You can also add custom item to the toolbar on top of a Display and Edit form.
    • Sharepoint Custom Toolbar
  • Custom Edit Control Block 
    • What’s more is that you could also add custom item to the edit control block that appears when you clicked on the title’s link.
    • Sharepoint Edit Control Block
  • There are a lot more locations you could customize. For the complete list, see: http://msdn.microsoft.com/en-us/library/bb802730.aspx (Default Custom Action Locations and IDs).

So, basically to add our own custom item, we need to add stuff to the element.xml file within your feature solution. This file not only contains the Module element, which provisions aspx files going into Sharepoint site, it also can contain elements such as Receiver (i.e. when you implement event receiver), as well as CustomAction.

For a better understanding of Element.xml file, visit: http://jason-xge2.blogspot.com/2007/07/elementxml-explained.html

CustomAction tag:

The syntax of CustomAction tag is as follow:

<CustomAction
  RequiredAdmin = "Delegated | Farm | Machine"
  ControlAssembly = "Text"
  ControlClass = "Text"
  ControlSrc = "Text"
  Description = "Text"
  FeatureId = "Text"
  GroupId = "Text"
  Id = "Text"
  ImageUrl = "Text"
  Location = "Text"
  RegistrationId = "Text"
  RegistrationType = "Text"
  RequireSiteAdministrator = "TRUE" | "FALSE"
  Rights = "Text"
  RootWebOnly = "TRUE" | "FALSE"
  ScriptSrc = "Text"
  ScriptBlock = "Text"
  Sequence = "Integer"
  ShowInLists = "TRUE" | "FALSE"
  ShowInReadOnlyContentTypes = "TRUE" | "FALSE"
  ShowInSealedContentTypes = "TRUE" | "FALSE"
  Title = "Text"
  UIVersion = "Integer">
</CustomAction>

Source: http://msdn.microsoft.com/en-us/library/ms460194.aspx

Customware.net has a very detailed list of examples of implementing custom items: http://www.customware.net/repository/pages/viewpage.action?pageId=69173255

Categories: Sharepoint 2007
Tags: