Recently I needed to add a special upload function to a custom Document Library definition that I created. In MOSS creating a custom Document Library/List definition is 20 times more intuitive and easy than in the previous version of SharePoint. So what to do? First, you open the features directory underneath the 12 hive (c:\program files\common files\microsoft shared\web server extensions\12\template\FEATURES). Create a copy of the list or document library feature that you would like to modify. Why create a copy? In my case I needed the new menu item to only be available for my new custom library, not in all document libraries. Our next step is to rename the folder of the feature we just copied to something that mnemonically represents the type of feature we are creating. Next, open the feature.xml file in our feature folder. Then, we need to generate a unique GUID for our new feature. You can generate a GUID inside of Visual Studio or go to the web and there is one on Microsoft's site. Or if your lazy like me type GUID generator in your friendly neighborhood Google search box and you will get plenty of web pages that will generate one for you. Under the Feature ID put your new GUID in place of the existing one. Ok, close the feature.xml were ready to open the next xml file. Our next step is to open the list templates folder and change the list template type number (the first element under the elements node in the file we just opened) from its current number to a new number. Now, if you read Microsoft's example on the technet website they use the number 20, don't do this. This inside word I have received was to use a number greater than 10,000 for your list template type such as 10009. Ok edit the rest of the obvious things like the display name, the description, and even add in a custom icon to show up next to the list/document library type on the create page. Ok we're ready to add our new menu item to our custom feature. We now need to add a CustomAction node inside of the elements node below the listtemplate area. The custom action is what is used to create our new menu item.
|
<CustomAction Id="MyCustomMenuAction"
|
Creates a name for our new custom action
|
|
RegistrationType="List"
|
Sets the type of item this custom action will affect. Other possibilities are ContentType, FileType, ProgId
|
|
RegistrationId="10009"
|
KEY! This says only show this custom action in list templates of type 10009, therefore not everything!
|
|
GroupId="UploadMenu"
|
Sets the group which the new menu item will show up in. Other possibilities are any CustomActionGroup that you have defined, ActionsMenu, etc.
|
|
Location="Microsoft.SharePoint.StandardMenu"
|
The location in which the custom action will be made available. In this case it will be on the standard menu within lists/document libraries. Other options are EditControlBlock, NewFormToolBar, DisplayFormToolBar, EditFormToolBar
|
|
Sequence="1001
|
Specifies the sequence in which this new control will be displayed on the menu referenced by the groupID.
|
|
Title="Custom Upload Item"
|
Title of action the user will see on the menu.
|
|
ImageUrl="/_layouts/images/custom/CustomMenuItemIcon.jpg"
|
Specifies the icon associated with this menu item.
|
|
Description="Create a custom action in the upload menu.">
|
Description text that will go below the title of this action.
|
|
<UrlAction Url="/_layouts/myCustomPage.aspx?listName={ListId}"/>
|
The {ListId} token passes the internal unique identifier GUID for the list in the query string so you can know which list you came from. Other possibilities are {SiteId}.
|
|
</CustomAction>
|
|
A complete list of all of the attributes, some of the possible values, and purpose available within the customaction's node please visit http://msdn2.microsoft.com/en-us/library/ms460194.aspx.
Save all our changes and were ready to deploy.
Open a command prompt and navigate to the bin directory of the 12 hive ( address listed above 12\bin). In the command prompt type
stsadm.exe –o installfeature –name MyListTemplateFolderName\feature.xml –force
stsadm.exe –o activatefeature –name MyListTemplateFolderName –url http://SharepointSite/SiteCollectionName -force
So what are those steps again in an easy to follow guide that are not filled with my fluff and tangents?
- Copy the default document library Feature Folder and renamed it.
- Change the feature ID under Feature.XML to a unique guid <Feature Id="29AFAA71-E117-4E80-AA17-D0C71B360233"
-
Open the listTemplates folder and edit the DocumentLibrary.xml
- Change the Type="101" to a number greater than 10,000.
- Change the display name
- Change the description
-
Add a custom action block underneath the list template element in the elements node.
-
<CustomAction Id="MyCustomMenuAction"
RegistrationType="List"
RegistrationId="10009"
GroupId="UploadMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1001"
Title="Custom Upload Item"
ImageUrl="/_layouts/images/custom/CustomMenuItemIcon.jpg"
Description="Create a custom action in the upload menu.">
<UrlAction Url="/_layouts/myCustomPage.aspx?listName={ListId}"/>
</CustomAction>
- Now set the Registration ID to the number you set as the type in the listTemplate node (10009)
- Deploy the feature now with stsadm.exe
- Activate the feature with stsadm.exe
Finally, if you would like to create new menu items and apply them to existing libraries, menus, lists, or administration areas you can do this by simply creating a feature that does not include a list template. To do so, create a folder in the features folder of the 12 hive. In the new folder create text file and name it feature.xml (MUST BE CALLED FEATURE.XML). Insert our xml into page.
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="InsertUniqueGUIDHERE"
Title="OZ Document Management Library"
Description="This Feature adds a new menu item to the upload menu "
Version="1.0.0.0"
Scope="Web"
Hidden="TRUE"
ActivateOnDefault="FALSE"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="MenuItem.xml" />
</ElementManifests>
</Feature>
Now create another text file, call it MenuItem.xml, and insert elements node with our custom action inside of it
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!—This custom action adds the menu item to all Document Libraries (type=101) -->
<CustomAction Id="MyCustomMenuAction"
RegistrationType="List"
RegistrationId="101"
GroupId="UploadMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1001"
Title="Custom Upload Item"
ImageUrl="/_layouts/images/custom/CustomMenuItemIcon.jpg"
Description="Create a custom action in the upload menu.">
<UrlAction Url="/_layouts/myCustomPage.aspx?listName={ListId}"/>
</CustomAction>
</Elements>
Hope this post has been helpful. IT took up about half of my flight from Houston to Fort Lauderdale to write, so mission accomplished. I was entertained and hopefully you are enlightened.