2

I have elements.xml with module:

<Elements>
  <Module Name="IntranetNewsPageLayout" Url="_catalogs/masterpage">
    <File Path="IntranetNewsPageLayout\IntranetNewsPageLayout.aspx" Url="IntranetNewsPageLayout.aspx" Type="GhostableInLibrary" >
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
      <Property Name="PublishingAssociatedContentType" Value=";#IntranetNews;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00efac964741834409bf9e0e0d275d511d;#" />
      <Property Name="Title" Value="Intranet News Article" />
    </File>
 </Module>
</Elements>

So IntranetNews content type is used for page layout IntranetNewsPageLayout.aspx. I want to use same page layout for new content type. How to do this? Should i create new File section or maybe new Module section?

2 Answers 2

2

You can do it via Visual Studio. Just add multiple file tags with different Url and refer as multiple content typesas follows:

<File Path="Website.Publishing.aspx" Url="Website.Publishing.aspx" 
        IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary">
        <Property Name="PublishingAssociatedContentType" 
           Value=";#$Resources:res,ctype;;<content type id>;#" /> 
</File>
<File Path="Website.Publishing.aspx" Url="Website.SomethingElse.aspx" 
        IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary">
        <Property Name="PublishingAssociatedContentType" 
           Value=";#$Resources:res,ctype;;<another content type id>;#" /> 
</File>

See an example: http://www.sharepointblues.com/2010/04/21/single-page-layout-for-several-content-types/

1

A page layout in SharePoint can only be tied to one content type. However, you can deploy the same layout under two different URLs and bind each to the separate content types, as they do here.

Another option that should work would be to create a single parent content type that has all of the required fields and bind the page layout to that type. You would then create child content types that inherit from the parent content type and the page layout would be available to them since they inherit from it. This approach is a little less explicit but would eliminate the need to have two identical layouts deployed to the _catalog.

1
  • 1
    Dave, we can surely add multiple content types to one page layout through visual studio. Commented Jan 6, 2013 at 17:12

Your Answer

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

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