Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

There's plenty of documentation online on how to configure a List Definition project to create a single list using a custom content type, but how does one go about creating a project that contains multiple content types that create several lists? If custom content types for one list are defined in its instance's Elements.xml, how would another list instance use those content types? Finally, how can I get the list definition project applied to several SharePoint sites?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

As mentioned, create a project with multiple features. Here is how I typically do it:

  • Feature 1 = Site Columns and Content Types (sometimes I'll separate Content Types into different features)
  • Feature 2 = List Definitions (aka List Templates)
  • Feature 3 = List Instances (if applicable)
  • Feature 4 = "empty" feature with Activation Dependencies on the other three features, with activation dependencies specified in order.

Usually only the "empty" feature is Visible (i.e. all others are set to Visible=False). This is similar to how the TeamCollab feature (which is responsible for deploying the out-of-the-box list templates). Look at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\TeamCollab by default to see it.

I don't like having so many SharePoint Project Items all over my project, so typically, I will add a Content Type SPI called "Content Types". Then as I add other Content Types, I'll design them and move them over into the Elements.xml file of the original "Content Types" SPI (so that all the Content Types are defined in a single Elements.xml file). I keep all Fields in a separate "Empty SharePoint Project Item", again in a single "Elements.xml". Because List Definitions require a special folder setup for deployment, I keep all List Definitions as separate SPI items, but just use the Feature Packaging Manager to include them all in a single feature.

I think there are exmaples of this in the Inside SharePoint 2010 book from MS Press. Here is a link to download the companion code: http://examples.oreilly.com/9780735627468-files/

share|improve this answer
    
What does "SPI" stand for? 'SharePoint Project Item'? –  Daryl Apr 24 '12 at 0:38
    
Yes, exactly. Basically one of the Visual Studio project item templates, such as Content Type, Module, List Defintion, Empty Element, etc. –  Brian Apr 24 '12 at 12:40
add comment

I usually prefer to use one feature that deploys custom content types and an another feature to deploy list definitions. When deploying activate custom content types first and then the list definiton feature.

As long as you use same contenttypeid in your schema.xml to reference your contenttype you defined in your content type feature, it should be fine. The content type need not be defined in the same module. You can specify something like below in your schema.xml.

<ContentTypes>
      <ContentTypeRef ID="0x1234567890"></ContentTypeRef>
</ContentTypes>
share|improve this answer
    
FYI...I've had problems with <ContentTypeRef> working in List Definitions within Sandboxed Solutions. May want to use <ContentType Inherits="TRUE"> instead. –  Brian Mar 23 '12 at 19:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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