March 28, 2012

SharePoint Content Types

SharePoint content types are a powerful way of customizing the Sites. Content Types define a  list item or group of list items in a List or Document Library. Content Types themselves contain a group of Site/user defined columns.

Imagine a scenario where you want to maintain a List of all customers of a company named "Doe wines". For this we should create a List called as "Customers". However, there are two types of customers of "Doe wines", one type of customers are individuals and the other type are companies. The data related to individuals and Companies will also differ. For example Individuals will have a First and Last name, Date of Birth etc. Companies may have Names, License type etc.

So to maintain both type of data in a single List we can use Content Types. We can create one Content Type called as IndividualCT and one more called as CompanyCT. Both will have their own set of columns.

Now in the Customers List we can just select New->CompanyCT and then create a customer who is a company. Similarly, we can create a customer who is an Individual by going to New->IndividualCT. Here both will be maintained in the same customer list.



March 27, 2012

What is a Feature?

People new to SharePoint must be wondering what a Feature is. So here it is, SharePoint Features are components which adds extra functionality to the site and can by Activated or De-activated by a Farm/Site/Web Admin.


Features can do lot of functions and adds lot of value to a Site. We can create a feature that can add extra menu items or do some validation etc.

Feature consists of two XML files. One is feature.xml and the other is a manifest file (like elements.xml). Feature.xml file simply informs SharePoint that a feature exists and can be activated/de-activated.

An example of feature.xml file is shown below: -
<Feature
  Id="[GUID]"
  Title="Hello World Feature"
  Description="A feature for Praveen's blog"
  Scope="Site"
  Hidden="FALSE"
  ImageUrl="classicmenu.gif"
  xmlns="http://schemas.microsoft.com/sharepoint/">

  <ElementManifests>
    <ElementManifest Location="elements.xml" />
  </ElementManifests>

</Feature>

The Manifest file is the one that describes the Feature. For example if a menu has to be added then what should be the menu name, description etc.

An example of a Manifest file is shown as below: -
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <CustomAction
    Id="NewMenu"
    GroupId="SiteActions"
    Location="Microsoft.SharePoint.StandardMenu"
    Sequence="201"
    Title="Hello Menu"
    Description="This is a classic menu"
    ImageUrl="_layouts/images/classicmenu.gif" >
      <UrlAction Url="http://techspoc.blogspot.com"/>
  </CustomAction>
</Elements>