2010年11月8日 星期一

Create List Item Menu on Specific List

1. Goto "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES" and create a folder (Exampel: CustomListItemMenu )

2. Create “Feature.xml”


<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="{C7B4AEEE-88D8-46eb-80AB-666228D19280}"
Scope="Web"
Title="Custom Action ***"
Version="1.0.0.0"
Description="Anything you can input">
<ElementManifests>
<ElementManifest Location="MenuItems.xml"/>
</ElementManifests>
</Feature>


3. Create “MenuItems.xml” which can be named anything else as long as you provide appropriate reference in “ElementManifest” section described above. Here is what we’ll have in our “MenuItems.xml”:

<?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Name of the action"
RegistrationType="ContentType"
ShowInLists = "True"
RegistrationId="0x010060E9BA54FF561C4E8F05788698ABF445"
Location="EditControlBlock"
Sequence="101"
Title="Open as Word 2003***"
>
<UrlAction Url="~site/_layouts/CustomAction.aspx?ID={ItemId}& amp;List={ListId}"/>

</CustomAction>

</Elements>

NOTE:
You need to find out
RegistrationType="ContentType" RegistrationId="0x010060E9BA54FF561C4E8F05788698ABF445"

1. Go Setting => List Settings => Advanced Settings
2. Select the Yes radio button on the “Allow management of content types”
3. Click OK
4. On the Setting page. Find the Content Type section and click on "item" or your default content type"
5. Copy the “ctype” value in URL as your RegistrationId
6. Copy this value into the RegistrationId attribute


If you want to do list type. Setting is:

RegistrationType="List"
RegistrationId="100"

RegistrationId = templateID
Go here to find out.



4. The key item in the definition above is to set the “RegistrationId” to the “ListTemplate” value we have taken down earlier. This will ensure the context menu item will be attached only to the types we have specified.

stsadm -o deactivatefeature -name CustomListItemMenu -url http://site -force
stsadm -o uninstallfeature -name CustomListItemMenu -force
stsadm -o execadmsvcjobs


stsadm.exe -o installfeature -name CustomListItemMenu
stsadm.exe -o activatefeature -name CustomListItemMenu -url http://site -force
stsadm -o execadmsvcjobs

iisreset

沒有留言:

張貼留言