SP Dev part 1 : Sharepoint 2007 Development model {Features}

Sharepoint A new feature in the Sharepoint 2007 is the "Feature" development style which means that every tiny and huge development task in the sharepoint is considered a "Feature".

Features can be activated or deactivated through a site administrator, which enables the very simple turn on/off of anything in the site.

Features are used for developing anything starting from a small button to a full site definition and tons of files and functions including webparts, workflows, lists, pages, content types, document libraries and others. I will try to include the development of all these topics in this series wish me luck and provide feedback. [more]

For a start I will show here in this part how to get started with the feature development and the basic elements and files needed for a developing and deploying a sharepoint feature.

Before opening the Visual Studio and starting to code, knowing what the files and where will they be deployed on the server will be mandatory. A very basic feature will include 2 xml files one named feature.xml and the other will hold the elements of this feature usually named elements.xml or elementsManifest.xml, consider that the files for any feature must be deployed in their own special directory inside the WSS system directory named FEATURES. The FEATURES directory is located inside another WSS system directory named TEMPLATE.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES

In our Hello sharepoint feature we will make a very basic feature named HelloSharepoint that when activated will add menu item in the SiteActions menu that will redirect to google.

Feature.xml

<Feature
Id="{INSERT-GUID-HERE}"
Title="Hello Sharepoint Feature"
Description="This is a custom feature which adds a custom item to link to google"
Scope="Web"
Hidden="FALSE"
ImageUrl="google.gif"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="ElementsManifest.xml" />
</ElementManifests>
</Feature>

As shown above the feature.xml looks very simple, only Id and Scope are the two required attributes and all the others are optional and a full list can be found here.

ElementsManifest.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="SiteActionsToolbar"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Title="Hello Sharepoint"
Sequence="100"
Description="A custom menu item links to google"
ImageUrl="_layouts/images/google.gif" >
<UrlAction Url="http://www.google.com"/>
</CustomAction>
</Elements>

And the elementsManifest.xml here describes the elements to be installed with the feature and we only define one element (a CustomAction) you find a bunch of types of elements to be added here.

That's all we are done with building our very first feature inside the WSS/MOSS world, I know some of the attributes here seem vague and other seem simple anyway I will try to put a part or two for only discussing these files with their various options.

 

Deploying the feature

 

  1. Copying the feature files (feature.xml and elementsManifest.xml) in the Features server path
    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES , and the google.gif in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\images
  2. Running STSADM.EXE operation to install the feature with WSS/MOSS "stsadm -o InstallFeature -filename HelloSharepoint\feature.xml -force"
  3. Restarting IIS
  4. Finally, activating the features within the site administration

SPpart1.zip (6.74 kb)

This entry was posted in Sharepoint. Bookmark the permalink.

One Response to SP Dev part 1 : Sharepoint 2007 Development model {Features}

  1. interesting! a good start shows the type of ur next posts, keep going I’ll be following them, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>