DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Archive for the ‘Site Definition’ Category

How to add a SPFeatureReceiver to a Custom ListInstance?

Posted by PANVEGA on January 19, 2009

In reference to my previous post about binding a Custom ContentType to a new ListInstance, I wanna solve this issues belowe with a SPFeatureReceiver class in Visual Studio.

First off the default view of your list does not contain those custom columns. When you select the item you will of course see all of your columns but they aren’t listed in the default view. Secondly the default content type for the list is still available to the user. In the case of a generic list the “Item” content type is still present. So when a user enters a new item they are able to select Item or your custom content type. This may not be desirable. Also if you are using the API to insert a new item into the list it will use the list’s default content type instead of the one you may be expecting. Once again this may not be desirable.

To overcome these restrictions we’re going to create a generic feature receiver that can be reused on any implementation using this technique. Read the rest of this entry »


Posted in C#, Custom Content Types, Deployment, DotNet, Event Receivers, MasterPage, MOSS, Object Model, Site Definition | Tagged: , , , , , , , , | Leave a Comment »

How to create a new List Item Instance with a Feature

Posted by PANVEGA on January 18, 2009

List Instances

A list instance is a list created by using a list template. When creating a list this way, you can override some of the list properties set in the template, and you can include data rows that will also be created as list items in the list. In this example we gonna create a Custom List Instance called BannerList. Read the rest of this entry »

Posted in Event Receivers, MOSS, Site Definition, XML | Tagged: , , , , | Leave a Comment »

Introduction in Feature Stapling

Posted by PANVEGA on January 7, 2009

The focus of this article is going to be on a concept called Feature Stapling. Most, if not all, SharePoint developers know that Microsoft frowns on modifications to the “Microsoft” owned files that support SharePoint. If you modify these files you run the risk of your changes being broken with the installation of a service pack or hot fix.

Feature Stapling allows you to create a feature and then associate it with any site definition without ever touching the site definition files themselves. The Feature Stapling applies to all new instances of sites that use a given site definition, without modifying the site definition or creating code routines to activate the Feature on each site.  Your feature will be executed when the site is being provisioned. Read the rest of this entry »

Posted in Deployment, MOSS, Site Definition | Tagged: , | Leave a Comment »

How to create a Custom Site Definition

Posted by PANVEGA on November 26, 2007


A site definition defines a unique type of SharePoint site. There are five site definitions natively installed in Windows SharePoint Services. A site definition can include more than one site definition configuration. SharePoint Web sites are based on particular site defnition configurations.

  • STS includes the site definition configurations for Team Site, Blank Site, and Document Workspace.
  • MPS includes the site definition configurations for Basic Meeting Workspace, Blank Meeting Workspace, Decision Meeting Workspace, Social Meeting Workspace, and Multipage Meeting Workspace.
  • CENTRALADMIN provides a site definition configuration sfor central administration Web sites.
  • WIKI provides a site definition configuration for Web sites that support community content using wiki technology.
  • BLOG provides a site definition configuration for blogs.

Each site definition consists of a combination of files that are placed in the \\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE subfolders of front-end Web servers during installation of Windows SharePoint Services. Site definition files include .xml, .aspx, .ascx, and .master page files, as well as document template files (.dot, .htm, and so on), and content files (.gif, .doc, and so on).

You can create a custom site definition by copying an existing site definition and then modifying the copy.

–> In this example I copied the Blog Site to a CustomBlog Site.

The WEBTEMP.XML Copy and Modification

The WEBTEMP.XML file contains the site definitions that are available on the Template Selection page for site creation. You never want to make modifications to the original WEBTEMP.XML file since upgrades and service packs can potentially overwrite any changes you have made.

Instead you create a copy of the WEBTEMP.XML file and append a unique name on the end. At run time the compiler merges all the information in the WEBTEMP*.XML files. So now we need to create our own WEBTEMP.XML file for our custom site definition so it will be available on the Template Selection page.

  • Go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates
  • Copy the Blog Site and rename it for e.g. CustomBlog
  • Navigate to the following directory on your SharePoint server:
    Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML
  • Copy the WEBTEMP.XML file and paste it in the same directory (Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML).
  • Give the file a unique name by appending a string to the name of the original file; for example, WebTempBlog.xml. At run time, the compiler merges information contained in this file with the information contained in the original file to specify which site definition configurations are available for creating new sites.
  • Open your new XML file (WebTempBlog.XML) in Notepad, an XML editor or a code editor.
  • Each WebTemp.xml file contains a collection of Template elements and Configuration subelements, which identify to the compiler all the site definition configurations that can be instantiated. The Configuration element defines, for example, a title, a description, the URL for the image displayed in the user interface (UI), and a display category that specifies the tab on which to display the template in the Template Selection section of the New SharePoint Site page.
  • Delete here all code between the TEMPLATEs tags. (only fot this simple example!)
  • In each Template element defined in the WebTemp file, the Name attribute must contain the same name that is assigned to the new folder. Also, to avoid conflict with IDs already used in Windows SharePoint Services, use unique values greater than 10,000 for the ID attribute.

The following example defines a single site definition.

<Template Name=”CUSTOMBLOG” ID=”10001“>
<Configuration ID=”0″ Title=”CustomBlog” Hidden=”FALSE”
Description=”A site for a person or team to post ideas,…”
DisplayCategory=”Collaboration” >

Notes about this code:

    TEMPLATE Element

    • The Name attribute must match your site definition folder name. It must match the name exactly and it is case sensitive. Use UPPERCASE.
    • The ID attribute must be unique and greater than 10,000.


    • ID is required and specifies a unique ID for the configuration.
    • Title is the name that appears on the Template Selection page. Your custom site definitions will appear under the default SharePoint list of Team Site, Document Workspace, etc.
    • Type is optional and identifies the configuration with a specific site definition.
    • Hidden specifies whether the site configuration appears as an option on the Template Selection page in SharePoint.
    • ImageURL is the large image you see on the Template Selection page. You can leave this as the default that SharePoint uses, or specify your own file. A way to use this would be to take a screenshot of the final site definition, create an image file suitable for the Template Selection screen, and specify that for this image so when the user is selecting a template upon site creation, they have a visual cue as to which template this one is.
    • Description is the text description that appears under the image on the Template Selection page. The description should describe the purpose or intended use of the template.
  • You may need to reset Internet Information Services (IIS) to cause the new definition configuration to appear as an option in the UI. To do this, enter iisreset at a command prompt.
  • Got to Site Actions –> Create Site under Collaboration for example you find the CustomBlog Site.


When Windows SharePoint Services 3.0 ships there are two tabs on the selection box in the Template Selection section of the New SharePoint Site page: “Collaboration” and “Meetings”. If you create a custom site template by saving an existing site as a template, then a third tab, called “Custom” will appear in the box.

If you use any value other than “Collaboration”, “Meetings”, or “Custom” as the value of the DisplayCategory attribute of a Configuration element in a WebTemp*.xml file, then a new tab with the new value as its name will appear in the box.

Read more

Posted in Deployment, Site Definition | Tagged: | 1 Comment »