Sunday, May 16, 2010

Custom Site Theme for SharePoint 2007 (MOSS 2007) and WSS 3.0

The easiest and the fastest way to apply the same look and feel on any SharePoint site is creating a site theme. A SharePoint site theme basically consists of theme.inf, theme.css, and image files. Theme.inf file simply represents the title of the theme. Theme.css is a stylesheet file that defines colors, header images and layouts of a site and image files can be referenced here to display on the page. By creating a custom site theme, you can easily change the style but in fact, writing and editing the stylesheet can be somewhat chanllenging when you have more than a hundred of elements to deal with.

Here is a short procedure of creating a custom site theme named "Ghost":

1. Copy any theme folder in "C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATETHEMES" folder and paste with its name replaced with "Ghost". In this example, copy GRANITE folder.

2. In Ghost folder, rename GRANITE.INF file to GHOST.INF in upper case.

3. Open GHOST.INF file with notepad.

4. Change the value of title under [Info] to Ghost.

5. Replace every word, Granite, under [titles] with Ghost.

6. Open "C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATELAYOUTS1033SPTHEMES.XML" file with notepad.

7. Add the following lines under tag:

Ghost
Ghost
Ghost theme.
images/thghost.gif
images/thghost.gif

Notice that preview and thumbnail paths are images/thghost.gif. By default, MOSS 2007 and WSS 3.0 will not have such image files.

8. In order to display thumbnail and preview correctly, you will need to capture the screen and save the file in "C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATEIMAGES" folder with thghost.gif name. You can change the .gif file name if you change the thumbnail and preview file names in tag.

9. Do an iisrest for the server to recognize the new theme.

Pretty simple procedure. Now you are ready to test your new theme. In Site Settings, you can now choose Ghost theme; however, the theme will not differ from Granite theme. Now, it is time for you to play with theme.css file!

Friday, May 14, 2010

How to create custom Visual Studio 2005 workflows for WSS 3 or Office SharePoint Server 2007

Software required to create Visual Studio workflows for SharePoint
Before you can start to create custom Visual Studio 2005 workflows that can run on a SharePoint server, you must install the following software:

Windows Server 2003 (a server you can develop on)
SQL Server 2005 (as a prerequisite for WSS 3.0)
Windows SharePoint Services 3.0
Visual Studio 2005
Microsoft .NET Framework 3.0
Visual Studio 2005 Extensions for Windows Workflow Foundation
Windows SharePoint Services 3.0 SDK
If you want to create Visual Studio 2005 workflows for Office SharePoint Server 2007 (MOSS 2007), you’ll need MOSS 2007 and the Office SharePoint Server 2007 SDK.

Creating a custom Visual Studio 2005 workflow for SharePoint
Building workflows for SharePoint is a challenging programming exercise, which is best tackled in small steps.

Once you have learned how to deploy your first workflow, you can concentrate on learning how to use and implement the Workflow Foundation activities that are specific to SharePoint.

Creating Visual Studio 2005 workflows for SharePoint is a 2-step process:

Design and write code for the workflow in Visual Studio 2005.
Deploy the workflow to a SharePoint server.



In this tutorial, you will create a very simple and basic workflow, so that you have a workflow you can deploy to SharePoint and concentrate on getting through your first deployment of a custom Visual Studio 2005 workflow to SharePoint instead of dealing with the difficulties of implementing workflows for SharePoint.

To create a custom Visual Studio 2005 workflow:

In Visual Studio 2005, create a new Project that is based on the Sequential Workflow Library template.
In the Solution Explorer, double-click the Workflow1.cs file to open the workflow designer.
Drag a LogToHistoryListActivty from the Toolbox and drop it under the onWorkflowActivated1 activity of the workflow.


Figure 1. Basic Sequential Workflow in Visual Studio 2005 for deployment to SharePoint.

Select logToHistoryListActivity1, and set its HistoryDescription property in the Properties window to The workflow has run..
Build the workflow project.
Installing the workflow on SharePoint
You can now proceed to deploying the Visual Studio 2005 workflow to SharePoint.

To deploy the Visual Studio workflow to SharePoint, you must:

Make the compiled DLL of the workflow a strong named assembly by signing it with a strong name key.
Deploy the assembly to the Global Assembly Cache (GAC) and retrieve its publicKeyToken. You will use the publicKeyToken in the workflow.xml file.
Add the appropriate XML to the feature.xml and workflow.xml files.
Modify the install.bat file by following the instructions in it. You can perform a Find and Replace to change the name of the workflow’s Feature folder and change localhost to point to your SharePoint server.
Run the install.bat file to install the workflow on SharePoint.
Once you have installed the workflow, you must associate the custom Visual Studio 2005 to a SharePoint list or library.

Running the workflow on a SharePoint list or library
In the following example, I created a custom SharePoint list called MyFirstWorkflowList and associated it with the workflow. I named the workflow attached to the list MyFWF and set it to run whenever a new item is created.

In the figure below, you can see that a workflow instance has run on a newly created item.


Figure 2. A workflow instance has completed on a SharePoint list item.

If you click on the text Completed in the MyFWF column, you will open the Workflow Status page, where you will see the comment The workflow has run. in the Workflow History list.


Figure 3. The Workflow Status page of the workflow instance that ran on the SharePoint list item.