Morten Andreasen

I am trying to provision a custom welcomepage using a module in a site definition, using the following syntax:

<Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;">
      <File Url="default.aspx" Type="GhostableInLibrary" >
        <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomWelcomePage.aspx, Custom Welcome Page" />
        <Property Name="Title" Value="Hello world" />
        <Property Name="ContentType" Value="MyCustomContentType" />
      </File>
</Module>

My page gets created using the PublishingPageLayout specified, however the underlying contenttype is set to Page.

MyCustomContentType inherits from page, and exists in the sitecollection when creating the site.

If i create a new page using my Page Layout "Custom Welcome Page" the underlying contenttype is correctly set to "MyCustomContentType"

Any help on this matter would be greatly appreciated



Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

fjusnes

You probably figured out this one by now, but anyway... You must use:

<Property Name="PublishingAssociatedContentType" Value=";#MyCustomContentType;#UniqueID;#" />

You will find the unique id by looking at the url for a content type. It is extensive and starts with 0x01.....

Frank





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Katrien De Graeve

I have been able to use this setting, works fine but according to what I do you should change the value to twice the name of the page:

<Module ....>
<File Url="default.aspx" Type="GhostableInLibrary" >

<Property Name="Title" Value="Hello World" />

<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx, ~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx" />

<Property Name="ContentType" Value="MyContentType" />

...
</Module>

So, the only thing you are missing is that you typed in the name (and not URL) of the page layout as the second value of your property.

Hope this helps!





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Morten Andreasen

Thank you Frank and Katrien for your responses

However i have still not been able to provision my default page using your input.

I have tried almost every possible combination of ContentType, PublishingAssociatedContentType and PublishingPageLayout

<Module Name="CustomHome" Url="$Resources:cmscore,List_Pages_UrlName;">
<File Url="default.aspx" Type="GhostableInLibrary" >
<Property Name="Title" Value="Yahoo" />
<Property Name="MasterPageDescription" Value="$Resources:spscore,DefaultLayoutDescription;" />
<Property Name="ContentType" Value="Forsvaret Page" />
<Property Name="PublishingAssociatedContentType" Value=";#Forsvaret Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39004A85D16F25DBAB4B902092121646076801;#" />
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/Preview Images/cilayout_picker.gif, ~SiteCollection/_catalogs/masterpage/Preview Images/cilayout_picker.gif" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/fvr_WelcomePage.aspx, ~SiteCollection/_catalogs/masterpage/fvr_WelcomePage.aspx" />
</File>
</Module>

Have you successfully provisioned pages, based on a custom contenttype, using a sitedefinition





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Katrien De Graeve

Hi Morten,

I have already successfully implemented a custom site definition using custom content types, custom master pages and custom page layouts. It works really well.

Have you created your custom page layout and content types using features If yes you also need to heirs IDs tthem in the site or web features section of the onet XML file. If you are not using features then maybe this is why you have a problem

I'm actually only using the properties ContenType and PublishingPageLayout, not the PublishingAssociatedContentType.

Are you creating your site definition onet.xml file from scratch I used the BLANKINTERNET one as a starting point. You might not need all the configurations in that onet.xml file but it gives a good overview of properties and settings that can be used.





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Morten Andreasen

Hi Katrien

I think you have pinpointed the root of my problem!

I have deployed my contenttypes and pagelayouts using features. I have used the BLANKINTERNET as template for my sitedefinition.

What do you mean by "If yes you also need to heirs IDs tthem in the site or web features section of the onet XML file.

Should I include a reference to the feature in which i defined my content types

 





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Morten Andreasen

Hi Katrien

I digged further into my problem and have comed to the following conclusion:

The reason why my pages created with the SiteDefinition have their contenttypes set to Page, is beacuse the Pages library of the newly created site do not have my custom content types associated.

I have manged to overcome this by creating a new Feature with scope set to Web that adds my custom content types to the Pages Library before creating the pages, that seems to work.

Do you know if there is a declarative way to do this, it seems kindof developer unfriendly otherwise





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Daniel

hi,

I have exactly the same issue. Can you tell me, how do you write the web scoped feature What must I do I'm new on MOSS developing!!

Or Katrien: Can you post a sample how I can add the content type id to the onet.xml

thanks

Sorry 4 my very bad english

regards





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Morten Andreasen

Hi Daniel

You probavly figured this out by now, but here it comes

My Feature XML looks like:

<Feature Id="b1658282-7af8-44a9-95c4-373222d1d07f"

Title="Content Type Provisioner"

Description="This feature adds the specified contenttype to a publishing site"

Version="1.0.0.0"

Scope="Web"

Hidden="True"

DefaultResourceFile="core"

Creator="ProActive A/S"

ActivateOnDefault="True"

AlwaysForceInstall="True"

ImageUrl="PAFeature.gif"

ReceiverAssembly="ProActive.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58c74dd9a182ee8e"

ReceiverClass="ProActive.Deployment.ContentTypeProvisionerFeatureHandler"

xmlns="http://schemas.microsoft.com/sharepoint/">

<ElementManifests>

</ElementManifests>

</Feature>

The content of my Feature Event Reciever looks like:

public class ContentTypeProvisionerFeatureHandler : SPFeatureReceiver

{

public override void FeatureActivated(SPFeatureReceiverProperties properties)

{

SPWeb web = (SPWeb)properties.Feature.Parent;

if(PublishingWeb.IsPublishingWeb(web))

{

PublishingWeb pweb = PublishingWeb.GetPublishingWeb(web);

SPList pagesList = pweb.PagesList;

if(properties.Feature.Properties["ContentTypesToAdd"] != null)

{

string contentTypesToAdd = properties.Feature.Properties["ContentTypesToAdd"].Value;

foreach(string contentTypeName in contentTypesToAdd.Split(';'))

{

SPContentType contentType = web.Site.RootWeb.ContentTypes[contentTypeName];

pagesList.ContentTypes.Add(contentType);

}

}

web.Update();

}

}

......

}

In my onet.xml i have added the feature registration to the webfeatures section

<Feature ID="b1658282-7af8-44a9-95c4-373222d1d07f">

<!-- Content Type Provisioning -->

<Properties xmlns="http://schemas.microsoft.com/sharepoint/">

<Property Key="ContentTypesToAdd" Value="ProActive Page;Forsvaret Page;Artikel"/>

</Properties>

</Feature>

tadaah!




Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Katrien De Graeve

Morten, thanks for that extra post, this is exactly what I ended up doing as well.

I made a reference to such a feature in the onet.xml <WebFeatures> section and now every time a new site/sub-site is created the content types are automatically added to the Page's library of the new site.

Daniel, you must only specify the Content type name and the publishing page layout in the onet.xml file, not the ID. Then do as in Morten's post by using a feature to add the content type to the Page's library once the site is generated.





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

nxliu

many thanks Morten provide this programming style resolution, i came into this problem and spend a lot of time on trying every combination to provide the correct contenttype

i believe morten found the very reason:

"The reason why my pages created with the SiteDefinition have their contenttypes set to Page, is beacuse the Pages library of the newly created site do not have my custom content types associated."

the pages list is came from publishing feature, where you can find the pages folder, and schema.xml in pages folder, AFAIK the pages list is a list template, publishing feature contains a PagesListTemplate.xml file, and the associated contenttype is defined in schema.xml, to my surprise, it defined two contenttypes, Document and Folder:

<ContentTypes>
<ContentTypeRef ID="0x0101">
<Folder TargetName="Forms/Document" />
</ContentTypeRef>
<ContentTypeRef ID="0x0120" />
</ContentTypes>

not my expected contenttypes like Page, ArticlePage and WelcomePage, so originally pages list is not associated with page contenttype also,

my question is: blankinternetsite provisions default.aspx to pages list by solution as Morten provided or can you provision a publishing page to pages list with correct contenttype

anyone know how to associate the contenttypes with pages list in new fearue not within publishing feature





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Frank Jusnes

Hi Morten

You can do this declaratively by creating a content type binding feature like this:

feature.xml:

<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Id="<Your feature guid>"
Title="<Your feature title>" Scope="Web" Hidden="FALSE" Version="1.0.0.0">
<ElementManifests>
<ElementManifest Location="ContentTypeBinding.xml" />
</ElementManifests>
</Feature>

ContentTypeBinding.xml:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentTypeBinding ContentTypeId="0x.........." ListUrl="Pages" />
<ContentTypeBinding ContentTypeId="0x.........." ListUrl="Pages" />
</Elements>





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

nxliu

thanks, Frank, you are the man Smile you really shoot it Smile





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Morten Andreasen

Hi Frank

Thank you a million times, i will try to use ContentTypeBindings on my new deployment project.

I even opened a partner premier support case at Microsoft, and they were not able to point me in the right direction - i guess the one hande does not know what the other does!

you rule!

Morten





Re: SharePoint - Enterprise Content Management Provisioning Pages with custom contenttypes using SiteDefinitions

Flemming Carlsen

Hi,

I have been trying to use the ContentTypeBinding to the way that Frank just described it using a feature.

I have installed the feature manually through stsadm and then added a feature element entry in the configuration/webfeatures section in the onet.xml file for the site definition. The result of this is an "unknown error" message when I try to create a site based on the template. The eventlog just display an error "Value cannot be null" in the SPFeatureManager.EnsureFeaturesActivated.

If I create the site without referencing the feature in the onet.xml file, it completes with succes and if I then manually activate the feature using the UI of MOSS, then the feature gets activated and the contenttype gets associated with the Pages list.

I have tried a lot of combinations now and I seriously consider using a feature eventhandler, since it can be debugged and as Morten showed, can do the job. It is frustrating however, not to be able to debug and resolve what should be just a simple task.

I have added Activationdependencies to ensure that the feature defining the content type is activated beforehand. I have tried ading it to a toplevel site and sub level site - none of them works when using the contenttypebinding in the onel.xml file.

Any suggestions on how to solve this issue the declarative way is highly appreciated!