none
how to add content type on all site collection

    Question

  • Hello

    I have created a web application. Now I want to add couple of custom content type and associate metadata column for new site collection thru the code. What is the best approach?

    Avian

    Saturday, November 16, 2013 8:17 AM

Answers

All replies

  • There are a variety of ways to do it.  But personally I think creating a Site Collection Feature with a Feature Receiver is the best way to do it.  You'll need code if you want to hook up a metadata column, so I would do the whole provisioning in code.  Activating the Feature in any Site Collection will provide the same content type across all site collections.  

    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Saturday, November 16, 2013 1:39 PM
  • Thanks Paul.

    Can you please suggest some sample code for adding codent type using feature receiver?

    Avian

    Saturday, November 16, 2013 7:03 PM
  • Here's a sample of the code used to create a content type.  Just use the same code in a feature receiver to create the content type.

    http://msdn.microsoft.com/en-us/library/ff798370.aspx


    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Sunday, November 17, 2013 2:04 PM