Welcome!

.NET Authors: Bruce Armstrong, Pat Romanski, Liz McMillan, Yeshim Deniz, Dmitry Sotnikov

Related Topics: .NET

.NET: Article

Creating Custom Site Definitions in Microsoft Windows SharePoint Services

Basic Process and Best Practices

Enable Document Versioning
Now that we have a document library for change requests, we need to enable version control so we can track changes made to the document. This can be accomplished by using VersioningEnabled attributes of the List element such as:

<List xmlns:ows="Microsoft SharePoint" Name="Change Requests" Title="Change Requests"
VersioningEnabled="TRUE" Direction="0" Url="Change Requests" BaseType="1" >

ExecuteUrl
Although CAML is a powerful tool for customizing your site definition, you will more than likely run into issues that can not be solved while using it. A case in point is the configuration of content approval for a list. If you need to turn content approval on for a specified list within your site definition there is currently no way to do this using CAML. However, there is a project attribute, ExecuteUrl, that can be used to execute a page from a specified Url whenever a site is created. Using this attribute allows you to create a code module that you can use to work directly against the WSS object model. This is a great way for dealing with those requirements that don't seem to have an eloquent solution from within CAML. The one downside to ExecuteUrl is that it only works from the WSS create wizard, so it won't work when creating Area sites from the portal, nor will it work from custom code where SelfServiceCreate is being invoked. If you decide to use a build script for deleting/creating sites during development, remember that the ExecuteUrl will not be invoked.

<Project Title="Project Management Site" ListDir="Lists" xmlns:ows="Microsoft SharePoint"
ExecuteUrl="_layouts/ConfigureProjectManagement.aspx"

CustomJSUrl
SharePoint uses quite a few JavaScript functions for providing menu options and other client-side functionality. You may find a need to disable one or more menu items from one of the context menus within a SharePoint list or document library. These lists are generated by the ows.js file; this file should not be edited. SharePoint provides a great way to override functions in the ows.js file by allowing for site definitions to invoke a custom JavaScript file. The CustomJSUrl property is specified within the project element of the ONET.XML file for your site definition. SharePoint will include the url for the javascript file after the inclusion for the ows.js file, which allows you to override functions and/or create new functions. For this example we will use a file named pm-ows.js that has been placed in the layouts virtual directory.

<Project Title="Project Management Site" ListDir="Lists" xmlns:ows="Microsoft SharePoint"
CustomJSUrl="/_layouts/pm-ows.js">

You should always provide a value for the CustomJSUrl property even if you don't currently have a need to override anything in the ows.js file. Doing so will allow you to easily incorporate custom functionality after sites have been created with your new site definition.

Deployment
To deploy your site definition, all you have to do is copy the site definition folder and the corresponding WEBTEMP file to the target server (assuming that you haven't created any custom Web parts) and then restart IIS.

Conclusion
Custom site definitions give you quite a bit of flexibility for creating sites that meet the specific needs of your domain by allowing you to customize and extend SharePoint. When your application requires that custom features be developed, tested, and then applied in a consistent and repeatable manner, you should consider this approach. By following the best practices described in this article you can greatly reduce the complexity of the development process.

Resources

  • Creating a site definition: http://msdn.microsoft.com/library/default.asp?url=/ library/enus/spptsdk/html/tsptCustomExistingWebTemplate.asp
  • Introduction to CAML: http://msdn.microsoft.com/library/default.asp?url=/ library/enus/spptsdk/html/tscamlovIntroduction.asp
  • Web Part Development: http://msdn.microsoft.com/library/default.asp?url=/ library/enus/odc_sp2003_ta/html/sharepoint_northwindwebparts.asp
  • ONET.XML: http://msdn.microsoft.com/library/default.asp?url=/ library/enus/spptsdk/html/tscamlovONET.asp
  • Custom List: http://msdn.microsoft.com/library/default.asp?url=/ library/enus/spptsdk/html/tsptCreateListTemplate.asp
  • SCHEMA.XML: http://msdn.microsoft.com/library/default.asp?url=/ library/enus/spptsdk/html/tscamlovSCHEMA.asp
  • NAnt.SharePoint.Tasks: www.gotdotnet.com/Workspaces/Workspace.aspx?id=69fcc7ae-6e5a-4bd7-9c9506797bf854dd

    Sidebar

    VIRTUAL SITES
    SharePoint implements a powerful architecture for extensibility by allowing Web applications to be virtualized across all WSS and SPS sites. However, this may not be very intuitive to you if you have tried to add pages by placing them directly in the wwwroot folder for the default server. SharePoint is implemented as an ISAPI handler and is programmed to allow Web applications to be virtualized. The benefit to you is that you can create a Web application and make it available across all of your sites, provided you place it in the correct location. The WSS administration pages are implemented in this manner. These applications are located in the layouts virtual directory that is mapped to the C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS. (For example, all WSS sites have a settings.aspx page that is accessible by using the layouts/1033/settings.aspx url from any site.) If you wish to create a new Web application and you don't want it to be virtualized, you can either create an excluded path from ISS or create a new virtual server that can host the application.

  • More Stories By Kris Syverstad

    Kris Syverstad is a Microsoft Most Valuable Professional (MVP) for SharePoint Portal Server and a member of the Microsoft Collaboration &
    Portals Developer Advisory Council. He leads the Rocky Mountain SharePoint
    Users Group, and has been invited to present on SharePoint Best Practices to Microsoft Product Teams and at Microsoft's Architectural Summit.

    Comments (3) View Comments

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    Most Recent Comments
    shirley 11/04/08 01:03:31 AM EST

    We can assist here as we specialize in developing and implementing SharePoint – that’s all we do. There is more information on this at http://www.nsynergy.com/Services/Pages/default.aspx or mail to Mark.Davis@nsynergy.com

    Gery D. Dorazio 03/22/05 07:08:02 PM EST

    Kris,
    Your article is the most concise I have found without the fluff. It covers the same information found in most other lengthy articles but adds a few insightful tips such as the inhibiting of FP to edit the pages...nice. One thing I have not been able to find, and would really appreciate your comments about, is a best practices approach (or any approach for that matter) for ways to also make the WSS administration and shared pages look like the new site template. There are about 130 files in that shared templates folder and it appears once a user gets onto a site and clicks a list view for instance, they are stuck with the SP layout...except for using the AlternateHeader. Any insights would be very much appreciated.
    Thanks,
    Gery

    Amrita 02/21/05 01:09:36 AM EST

    Perfect,real nice explanation.