1

Currently I've got a custom site definition (SharePoint 2010) that includes several features and also puts some webparts in the webpartzones on the default.aspx when a site based on this definition is created. This works fine so far, but now I want to change the number and layout of the available webpart zones. I already created a new pagelayout that looks like I want:

<%@ Page language="C#"   Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" meta:webpartpageexpansion="full" %>  
<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>  
<%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>  

<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">  
    <SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>  
</asp:Content>  

<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server"> 
    <style type="text/css">
           .clearfix:before,
         .clearfix:after {
    content: " ";
    display: table;
    }
    .clearfix:after {
    clear: both;
    }
    .clearfix {
    *zoom: 1;
    }

    .left {
    float: left;        
    }

    .wpzone-left {
        width: 80%;
    }

    .wpzone-right {
        width: 20%;
    }
}
</style>


<WebPartPages:SPProxyWebPartManager runat="server" id="spproxywebpartmanager"></WebPartPages:SPProxyWebPartManager>
<div class="clearfix">
    <div>
        <WebPartPages:WebPartZone id="g_2B77BCE303404806BF11F38524B04EE7" runat="server" title="Header"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
    </div>

    <div class="left wpzone-left">
        <WebPartPages:WebPartZone id="g_C32EE71D668842E594AFD1E9F51303EE" runat="server" title="Left"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
    </div>
    <div class="left wpzone-right">
        <WebPartPages:WebPartZone id="g_8A8EB2A8290D42719116F76F6AE01F59" runat="server" title="Right"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
    </div>

    <div>
        <WebPartPages:WebPartZone id="g_72C6A932C0B74F1DBDD73839578FB477" runat="server" title="Footer"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
    </div>
</div>
</asp:Content>

The Page Layout path is ~sitecollection_catalogs\masterpage\PageLayoutRecord.aspx
It is checked in as major version and published.

In the onet.xml of the site definition I added the following: (because of this tutorial http://blogbaris.blogspot.be/2010/11/setting-default-page-layout-in-onetxml.html)

<WebFeatures>
    <!-- Publishing -->
    <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
        <Property Key="DefaultPageLayout" Value="~SiteCollection/_catalogs/masterpage/PageLayoutRecord.aspx"/>
      </Properties>
    </Feature>

The webparts are added to the default page via onet.xml as well:

<Modules>
<Module Name="DefaultBlank" Url="" Path="">
  <File Url="default.aspx" NavBarHome="True" Type="Ghostable">
    <NavBarPage Name="$Resources:core,nav_Home;" Url="~site" ID="1002" Position="Start" />
    <AllUsersWebPart WebPartZoneID="Header"
                     WebPartOrder="0">
      <![CDATA[
      <webParts>
        <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
          <metaData>
...
etc
...

But if I create a site based on the site definition the default page looks changed but it uses a page layout called hyperlinkpage or something like that. Why doesn't it use my pagelayout?

0

you have to add page layout to your file in onet.xml as such

    <File Url="default.aspx" Type="GhostableInLibrary">
      <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/PageLayoutRecord.aspx, Record Page Layout" />
    </File>

And if you have a Content type you can assign it as well, via

<Property Name="ContentType" Value="{YOUR CONTENT TYPE HERE}" />
  • Where exactly do I add this file tag? – Jessica May 7 '14 at 10:07
  • you added it to your Module File definition. look at this link for example stefan-stanev-sharepoint-blog.blogspot.com/2010/07/… – dotsa May 7 '14 at 18:59
  • Hm, I tried that now, but it still tries to use the WelcomeLinks PageLayout... and even fails in the end with "Failed to create modules from onet.xml when provisioning site at url "http://.../test1" with site definition "STS#0". " – Jessica May 8 '14 at 11:44
  • The modules part I used, now looks like this: <Modules> <Module Name="MyPages" SetupPath="SiteTemplates\SPS" Url="Pages"> <File Url="mypage.aspx" Path="default.aspx" Type="GhostableInLibrary"> <Property Name="Title" Value="Home" /> <Property Name="ContentType" Value="Welcome Page" /> <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/PageLayoutRecord.aspx" /> <NavBarPage Name="$Resources:core,nav_Home;" Url="~site" ID="1002" Position="Start" /> <AllUsersWebPart WebPartZoneID="Header" WebPartOrder="0"> – Jessica May 8 '14 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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