1

I have developed a custom content type and a custom page layout that is inheritted, in visual studio for my publishing site. I am setting the default page layout of the site programmatically, in event receiver(feature activated).But do i need to bind my custom content type to Pages library? If i should, then how to achieve this? Is ContentTypeBinding suitable for my situation. Or is it used only in site definitions?

<ContentTypeBinding
ContentTypeId="Text"
ListUrl="Text" 
RootWebOnly="TRUE" | "FALSE"/>

1 Answer 1

1

As soon as you are using the Page Layouts just for what they're intended to (that is, assigning it to a new page), I think it's not necessary to explicitly add the content type to the Pages Library.

Just by adding the Page Layout to the "_catalogs/masterpage" folder as "GhostableInLibrary", and associated with the needed content type, will make them available when you create a new page.

Example:

<Module Name="PageLayouts" Url="_catalogs/masterpage" RootWebOnly="TRUE">
    <File Path="PageLayouts\MyPageLayout.aspx" Url="MyPageLayout.aspx" Type="GhostableInLibrary">
        <Property Name="Title" Value="My Page Layout" />
        <Property Name="PublishingAssociatedContentType" Value=";#Welcome Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#" />
        <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
    </File>
</Module>

If, for another reason, you need the content type to be available on the Pages library, you can attach it programmatically in the same "FeatureActivated" event receiver, following a guideline such as the one provided in MSDN: http://msdn.microsoft.com/en-us/library/aa543576.aspx

1
  • 1
    As in your case you have to add this Custom Content type to Pages library, because you are using "Custom Content Type" and "Custom page layout". Above given answer is correct in case if you are using custom page layout but already existing content types in Pages Library, than offcourse you don't need to do that. Regards, faisal Dec 3, 2013 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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