Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to customize the landing page of a teamsite. The WikiPageHomePage feature sets the SitePages/Home.aspx as the default landing page. What I want to do is to deploy a new file to this library and add some webparts to the page. The file is deployed by a module in a web scoped feature. This feature is stapled to the teamsite definition. In the feature activated event I'm trying to add a webpart to this file. When the newly created web is a rootweb I can't get to the page yet in the feature activated event, because the file isn't there yet. So I'm running into the site provisioning order issue. Also described here: http://sharepointmagazine.net/articles/introduction-to-sharepoint-feature-stapling-part-2

Feature stapling doesn't seem to be the right approach in this case. Unfortunately I'm not allowed to create a site definition or a web template.

What are my options?


Thanks for the suggestion about CPP. I created a new webtemp file with a custom template name and setup a CPP:

<Template Name="TestProvision" ID="100000">
    <Configuration ID="0" Title="Test provision" Hidden="FALSE" 
                 ImageUrl="/_layouts/images/CPVW.gif" Description="Test provision"
                 DisplayCategory="Test Provision"
                 ProvisionAssembly="ProvisioningProvider, Version=1.0.0.0, 
                 Culture=neutral, PublicKeyToken=1e7bee723732232c" 
                 ProvisionClass="ProvisioningProvider.CustomProvisioningProvider"  
                 ProvisionData="">
    </Configuration>
  </Template>
public class CustomProvisioningProvider : SPWebProvisioningProvider
{
    public override void Provision(SPWebProvisioningProperties props)
    {
        SPWeb web = props.Web;
        web.ApplyWebTemplate("STS#0");
        web.Lists.Add("Test list", " Description 123", SPListTemplateType.GenericList);
        web.Update();
    }
}

This template shows up at the template selection when creating a site collection and the code in the CPP is processed. So far so good.

When I change the custom template name in the new webtemp file to STS, I would like SharePoint to process the code in the CPP when creating a site collection based on a team site, but it doesn't.

<Template Name="STS" ID="100000">
    <Configuration ID="0" Title="Test provision" Hidden="FALSE" 
          ImageUrl="/_layouts/images/CPVW.gif" Description="Test provision" 
          DisplayCategory="Test Provision"
          ProvisionAssembly="ProvisioningProvider, Version=1.0.0.0, Culture=neutral, 
          PublicKeyToken=1e7bee723732232c" 
          ProvisionClass="ProvisioningProvider.CustomProvisioningProvider" 
          ProvisionData="">
    </Configuration>
  </Template>

Is this possible at all or am I on the wrong track?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You could set this up in a custom provisioning provider (CPP). This only takes a new entry in a new webtemp file that points to your team site site definition.

When you have applied your template inside the CPP you are free to add what ever you need on the page, both by activating module features or by adding web parts in code.

Sample code for adding content to a meeting template:

class MeetingWorkspaceProvisioningProvider: SPWebProvisioningProvider
{
    public override void Provision(SPWebProvisioningProperties properties)
    {
        SPWeb site = properties.Web; // NOTE: dont dispose this web!

        // this is the ProvisionData attribute in your webtemp. 
        // I point this to an xml file 
        //  eg. ProvisionData="1030\xml\MyCustomer\ProvisioningData.xml"
        Dictionary<string, string> propertyValues = GetDictionaryFromXml(properties.Data); 

        // provision Blank Meeting Template
        site.ApplyWebTemplate("MPS#1");

        CreateLibraries(propertyValues, site); // here i add libraries
        CreatePages(propertyValues, site); // here i create pages
        AddListWebPartsToPages(propertyValues, site); // here i add list webparts
        AddContentEditorWebPart(propertyValues, site); // herei add content editor web part
        SetSiteLogo(propertyValues, site); // here i set site logo
    }

}
share|improve this answer
    
if you could edit the post with the code it will be easier to understand what you do. I have edited the answer above with sample code –  Anders Rask Feb 25 '11 at 14:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.