Tuesday, January 03, 2012

SharePoint 2010 Localized Publishing Web Template

When you try to create a new localized publishing site based on a minimal SharePoint 2010 publishing web template (or a similar minimal site definition), it might fail with a "CreateWelcomePage" error such as this:

System.Runtime.InteropServices.COMException (0x80070001): 0x80070001 at 
Microsoft.SharePoint.Library.SPRequestInternalClass.GetMetadataForUrl
(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, 
Int32& plType, Object& pvarFileOrFolder) at 
Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl
(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, 
Int32& plType, Object& pvarFileOrFolder) - 
-- End of inner exception stack trace --- at 
Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
  at 
Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl
(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, 
Int32& plType, Object& pvarFileOrFolder) at 
Microsoft.SharePoint.SPWeb.GetListItem
(String strUrl, Boolean bFields, String[] fields) at 
Microsoft.SharePoint.Publishing.PublishingWeb.GetPublishingPage(String strUrl) at 
Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.CreateWelcomePage
(PublishingWeb area, PageLayout pageLayout) at 
Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetDefaultPageProperties
(PublishingWeb area, Boolean& updateRequired) at 
Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.
InitializePublishingWebDefaults() 
- -- End of inner exception stack trace --- at 
Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.
InitializePublishingWebDefaults() at 
Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.Provision()
  at 
Microsoft.SharePoint.Publishing.PublishingFeatureHandler.<>c_DisplayClass3.b_0() at 
Microsoft.Office.Server.Utilities.CultureUtility.RunWithCultureScope
(CodeToRunWithCultureScope code) at 
Microsoft.SharePoint.Publishing.CmsSecurityUtilities.RunWithWebCulture
(SPWeb web, CodeToRun webCultureDependentCode) at 
Microsoft.SharePoint.Publishing.PublishingFeatureHandler.FeatureActivated
(SPFeatureReceiverProperties receiverProperties).

The typical cause is that your web template/site definition is a bit too minimal. The "Publishing" feature needs some initial configuration property data during feature activation. Don't strip these properties away completely. Also, activating the "Publishing" feature from code or a feature stapler will not work for localized sites if you don't pass in this configuration. It is not standard, but you can pass property XML data from code to feature activation as shown in Specifying Properties When Activating Features Through Code.

You must pass in the publishing feature property configuration for the "WelcomePageUrl" to ensure that is reference the localized pages library during activation, which is /sider/ for LCID 1044. The fallback for when this property is not set or is empty seems to be hardcoded to /pages/. Note that using "osrvcore" as the resource file is needed for some languages if you don't have SP1 of the language pack installed.

<!-- Feature: Publishing -->        
<Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">  
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
            <Property Key="ChromeMasterUrl" 
              Value="~SiteCollection/_catalogs/masterpage/puzzlepart.master" />
            <Property Key="WelcomePageUrl" 
              Value="$Resources:cmscore,List_Pages_UrlName;/default.aspx"/>

It is important to reference an existing page in an existing library as the welcome page (home page). Deploy a page using a module if needed. Note that not all of these properties need to be specified as they have working default settings as fallback.

2 comments:

Website Templates said...

Hello Friend, Here how can we create share point? I would like to understand really...

Erich Stehr said...

On a related note, I ran into the 0x80070001 error in a third-party site definition whenever I tried to create a subsite, but it would work in the root of a site collection. Placing the prescribed properties on the Publishing feature at web scope did nothing.

I eventually realized that they had placed the PublishingWeb feature before the Publishing feature in the ONET.XML. Apparently Publishing can be 'correctly' loaded by PublishingWeb if and only if it's at the root of the site collection. Swapping the elements so that Publishing is in place first let me build subsites with the template as well.