Saturday, 7 July 2012

Learning SharePoint from SharePoint

Last week I was so busy with my family so I could not get time to write anything. Luckily I have got some time this week.

To learn anything you would need some tools related to what you are going to learn, perhaps some books or some software etc.
For SharePoint we need following things:
1.       SharePoint environment offcourse
2.       A tool to decompile the SharePoint dll code (dotPeek or Reflector)
3.       Items you want to learn (For instances Site Template, Features, Layout Pages etc)

You can find everything related to SharePoint in 12/14 hive. Let’s get started!
Below is the snapshot of 14 hives (as I am using SharePoint 2010)

If you want to deploy your own custom WCF or ASMX web service, ISAP is the recommended place to use it. When you deploy in 14 hives it is recommended that you should use your own folder.

WebService / WCF Service Deployment Scenario
Let’s say I want to deploy a WCF that creates an Order and save it to SharePoint list/or database.

So folder structure would be:
14 hives \ ISAPI \ CompanyName \ ProjectName \ CreateOrder.svc

When you reference you would be referencing with http://SharePointSiteUrl/_vti_bin/CompanyName/ProjectName/CreateOrder.svc

Also you can get the url from IIS. Go to your IIS as shown below and select the CreateOrder.svc page and right click and click Browse option.

Application Pages deployment scenario

If you want to deploy your own custom application page, you should deploy all your custom application pages to 14 hives\TEMPLATE\LAYOUTS\CompanyName\ProjectName\YourCustomPage.aspx

SharePoint Resources (Images/CSS/JS) scenario

Images should go to:
14 hives\TEMPLATE\LAYOUTS\1033\Images\CompanyName\ProjectName\your images

CSS should go to:
14 hives\TEMPLATE\LAYOUTS\1033\STYLES\CompanyName\ProjectName\your css

Javascript files should go to:
14 hives\TEMPLATE\LAYOUTS\1033\ CompanyName\ProjectName\javascript files

Creating Site Template scenario

Browse 14 hives\TEMPLATE\Site Templates and pick the easiest one that is sts and inspect the folder structure and files. If you observe the structure then it will be easy for you to create a custom site template that you can deploy through SharePoint solutions.

All the configuration related to SharePoint template goes to 14 hives\TEMPLATE\1033\XML

Also have a look at xml files located above in the picture. It will tell how to create a configuration and Site Provisioning Provider.

Provisioning a web part to a page using XML declaration

If you open xml located at 14 hives\TEMPLATE\SiteTemplates\sts\xml  or ONET.xml of any SharePoint site template you can see the Module node. Below is a snapshot of Onet.xm file:

If you pay close attention to the red box you will notice that we are saying that we want that web-part (Members webpart) to be added to “Right” zone in that page with order “1”. It means this web-part will be displayed first.

The easiest way to get the xml for web part is to export the web-part from the page and open it to some notepad.

There are lot of things but what I wanted to share is that how you can explore SharePoint yourself.
Some of you guys must be thing where we have used dotPeek or Reflector. J You can use where you want to know how SharePoint is doing some of the stuff. So you can inspect Microsoft.SharePoint.dll or desired dll.

Happy talking about SharePoint !!!