为列表增加自定义菜单项,可以用content type的方式,在content type中加入custom actcion然后建基于此content type的列表
也可以单独将custom action 建成一个feature
You can create a custom action that is based on the list type by editing the elements.xml
file that is associated with the custom feature. However, you can also create a custom action that is specific to a list rather than a list type. To do this, create a custom feature for the content type and then make a minor modification in the elements.xml
file. The following steps demonstrate how to do this.
Create a custom content type
-
Create a custom content type by inheriting from any one of the standard Windows SharePoint Services content types.
-
Ensure that the identifier (ID) of your custom content type has the ID of the base content type (from which it inherits) as its ID prefix.
The following example XML code shows the
elements.xml
file for a custom content type that was inherited from the standard Windows SharePoint Services content type, in this case, the List content type.<?xml version="1.0" encoding="utf-8" ?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <ContentType ID="0x01AB" Name="MyCustomContentType" Group="MyCustomContentTypeGroup" Description="Customized Content Type" Version="0"> <FieldRefs> <FieldRef ID="{8c06beca-0777-48f7-91c7-6da68bc07b69}" Name="Created" DisplayName="Field1" /> <FieldRef ID="{1df5e554-ec7e-46a6-901d-d85a3881cb18}" Name="Author" DisplayName="Field2" /> </FieldRefs> </ContentType> </Elements>
Feature.xml<?xml version="1.0" encoding="utf-8"?> <Feature Id="BCCBAE5C-C27C-408b-A68E-49E6482FEC4F" Title="custome content type 222" Description="Creates Custom content type action" Version="12.0.0.0" Hidden="TRUE" Scope="Site" xmlns="http://schemas.microsoft.com/sharepoint/"> <ElementManifests> <ElementManifest Location="elements.xml"/> </ElementManifests> </Feature>
Create your custom action
-
In the
Elements.xml
file, create your custom action, as illustrated in the example following. add flowing to elements.xml<!-- Document Library Toolbar New Menu Dropdown --> <CustomAction Id="UserInterfaceLightUp.DocLibNewToolbar" RegistrationType="ContentType" RegistrationId="0x01AB" Rights="ManagePermissions" Location="EditControlBlock" Sequence="1000" Title="MY DOCLIB NEW MENU TOOLBAR BUTTON"> <UrlAction Url="/_layouts/LightupHello.aspx?NewMenu"/> </CustomAction>
Create the list
-
Create the list where you want to render the custom action.
-
Change the default content type of the new list to the custom content type that you created above.
-
Delete the Item content type from the list. At this point, the custom action will be rendered in the Edit Control Block menu of the specified list.
http://msdn.microsoft.com/en-us/library/cc768562(v=office.12).aspx
Customization of SharePoint list menu item – Part 1 add Custom Action Item
Posted by chrissyz on June 6, 2009
It has been a while since last time I blogged. And I do feel bad about being ignorant of my blog for such a long time. So this time I am gonna show some code to feed those hungry souls. Today I would like to talk about adding a list menu item through feature. This example is to add a menu item in a calendar list.
We all know a feature includes two files, feature.xml and elements.xml
In our feature.xml, nothing special, it will look like any other normal
feature.xml
<?xml version=“1.0“encoding=“utf-8“?>
<Feature Id=“GUID”
Title=”Calender list Menu“
Description=“Creates Custom Action in Calender list item menu”
Version=“12.0.0.0″
Hidden=“TRUE”
Scope=“Site“
xmlns=“http://schemas.microsoft.com/sharepoint/“>
<ElementManifests>
<ElementManifest Location=“elements.xml“/>
</ElementManifests>
</Feature>
Then comes the elements.xml
<?xml version=“1.0“encoding=“utf-8“?>
<Elements xmlns=“http://schemas.microsoft.com/sharepoint/“>
<CustomAction
Id=“F699684E-3127-428e-BF2B-EA71CA6E36C8“
RegistrationType=“List“
RegistrationId=“106“
Location=“EditControlBlock“
Sequence=“1000“
Title=“Calendar Custom Action“>
<UrlAction
Url=“~site/YourPageLibrary/YourCustomPage.aspx?ID={ItemId}&List={ListId}“/>
</CustomAction>
</Elements>
RegistrationType can be “ContentType”, “FileType” (for example if you only want your feature appear to .xsn file), list and Prog ID.
The RegistrationID element is used to specifiy the ID of RegistrationType. If RegistrationType is “ContentType”, to get Registration ID, open the document library settings, in the ContentType section click on the content type you
choose, then grab the hex string in the url after “ctype=” parameter.
If you use FileType as RegistrationType, then just add the “.doc” or “.xls” etc in the RegistrationID
If the RegistrationType is list or ProgID, John Holiday has a blog summarized all the RegistrationID, look it up!
参考: