Custom Content Types:
As described in a previous blog titled “Office 2007 Features” the new way to create and deploy custom types and code in Office 2007 Server is to use Features. This blog describes how to build a custom Content Type and its deployment as a feature. The feature adds an additional item to the toolbar’s Action Menu.
A feature is defined as a logical collection of items and methods and is considered the modular building block for Office 2007. It is comprised of one or more Xml files, each with a specific role in the structure or makeup of the feature.
Step 1. Create PBC Custom Menu feature.
The custom feature will be created using Visual Studio 2005 but the technique can be implemented in many other technologies including the old reliable NotePad technology.
- Open up VS2005 and create a new Class Library project called SPSFeatures.
- Create a folder structure in the Solution Explorer as follows:
Features (root Folder)
PBCMenu (This is name of the Feature)
- In the PBCMenu folder, add an .xml file called Feature.xml (this name is a system requirement)
- To enable Intellisense in the Xml add a Schema reference in the page properties:
C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATEXMLwss12.xsd
- Add this code to Feature.Xml where:
Id: A new GUID generated with Tools> Create GUID (in registry format).
ElementMaifest/Location: The relative path to the second .Xml generated above.
<Feature Id="626BEB89-5A13-46f5-A2A2-0790E85FE66A"
Title="PBC Custom Menu"
Description="Custom nenu by PointBridge Solutions LLC"
Version="1.0.0.1"
Scope="Site"
Hidden="FALSE"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="PBCMenuElements.xml" />
</ElementManifests>
</Feature>
The Feature file lists all the components to be used either directly or using the ElementManifest element.
- Add another file to the PBCMenu folder called PBCMenuElements.xml (or a name of your choosing, editing the Feature.xml ElementManifest element appropriately).
Again add a reference to the wss12.xml schema file through the page’s Schema property.
- Add the following to PBCMenuElements.Xml where:
GroupId: SiteActions is the system name for the target menu.
Location: Menu library reference
Sequence: Position in dropdown
UrlAction: Target page of the new menu item.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="PointBridge.ActionMenu"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
Title="PointBridge Custom Action Menu">
<UrlAction Url="PBCMenu.aspx"/>
</CustomAction>
<Module Name="SamplePage" Url="" Path="">
<File Url="PBCMenu.aspx" />
</Module>
</Elements>
The Module element specifies the page for the UrlAction element.
Create this page PBCMenu.aspx and add the following content:
<%@ Page Language="C#" Inherits="System.Web.UI.Page"%>
<%
Response.Write("<p align=’center’>This is a PointBridge hello world test page!!!!</p>");
%>
This is a very simple page. To build a page that uses the default.master page copy the contents from a standard page from _layouts directory.
Step 2. Install the custom menu feature.
- Copy the folders under Features from the project directory and paste them into:
C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATEFEATURES.
It is best to do this from the command prompt to avoid any folder permissions problems.
The PBCMenu folder is also the name of the feature.
- Install the feature using StsAdm.exe:
"C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12BINSTSADM.exe" -o installfeature -filename PBCMenuFeature.xml" –force
- Reset the web server: IISReset from the command prompt (not required for the initial installation).
The feature can now be activated in the Features Settings page. (see figure 1)
Test the feature by returning to the home page and open the Action menu and see the new item (see Figure 2).
In the next blog I will be building a custom document library and also provide a download link for the code mentioned above.
Figure 1 – Activating a newly installed feature
Figure 2 – Custom Action menu in……..action