Friday, March 27, 2009

Add a custom menu to the list

Change the elements.xml described in last blog posting to add a menu item to the menu which appears when you edit a document item


<CustomAction Id="ListMenuForMyPage"
  RegistrationType="List"
  RegistrationId="101"
  ImageUrl="/_layouts/images/GORTL.GIF"
  Location="EditControlBlock"
  Sequence="105"
  Title="My Page" >

  <UrlAction Url="~site/_layouts/CustomPages/MyPage.aspx?ItemId={ItemId}&amp;ListId={ListId}"
    />
</CustomAction>

This CustomAction element is different than what you have seen before because it has a RegistrationType attribute that is assigned a value of List. It also is configured with a RegstrationID attribute that is assigned a value of 101. Note that 101 is a list type identifier that applies to all document libraries. You should also notice that the Location attribute has a value of EditControlBlock, which creates the effect of adding the menu item to the ECB menu of documents within a document library.

Note the {ListId} token and the {ItemId} token within the UrlAction Url’s QueryString. MOSS dynamically replaces them  with list GUID and itemId

0 comments: