Showing posts with label SiteDefinition. Show all posts
Showing posts with label SiteDefinition. Show all posts

Wednesday, November 28, 2007

Deploying Publishing Content Types via Site Definition

First let me say welcome to my blog!

Recently I've been working on a project that involved some heavy branding of a custom publishing site.

I had to create the following custom items:
  • Publishing Site Definitions
  • Master Pages
  • Site Columns
  • Content Types (Using the custom site columns)
  • Page Layouts (Using the custom content types)
  • Images
  • CSS Files
All of this had to be deployable via features and solutions.

To accomplish this I created some custom site definitions and deployed the necessary branding files via a feature that was attached to the site definition. However, when my site definition was created my custom content types were not attached to the pages library resulting in a page that correctly used my page layout but was lacking the support fields behind the scenes.

To remedy this I had to create an additional feature which I called my ContentTypeBindingFeature and attached it to my site definition. This solved my problem.

Example code below:

feature.xml

<?xml version="1.0" encoding="utf-8" ?>
<Feature
Id="INSERT_YOUR_GUID"
Title="Content Type Binder"
Description="Binds a specified content type to the pages library"
Scope="Web"
Hidden="TRUE"
Version="1.0.0.0"
xmlns="http://schemas.microsoft.com/sharepoint/">
<elementmanifests>
<elementmanifest location="ContentTypeBinding.xml">
</elementmanifests>
</feature>

ContentTypeBinding.xml

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentTypeBinding ContentTypeId="INSERT_YOUR_CONTENT_TYPE_ID" ListUrl="Pages" />
</Elements>