Search code examples
sharepointsharepoint-2007mosscaml

Default Content Type and Content type order using Folders in a Sharepoint List


I have a Custom List Definition (schema.xml) i have set up Site Columns (through A feature) and numerous content types also through a feature, this all works fine. I have a list definition (schema.xml) and i have put the content types at the top in the order i want them to appear (assuming that the top content type will be the default for the list - which is what i want)

NOTE: i HAVE set

EnableContentTypes="true" 

here is an excerpt from my schema.xml

<ContentTypes>
  <!-- Folder based content type -->
  <ContentTypeRef ID="0x0120006ad66a4924644ac98d371a0e069c5d99" />
  <!-- Item Based Content Type -->
  <ContentTypeRef ID="0x0100a18ddd58b9384567bc776a3c5889ea77" />
  <!--   ..... more content types ...  -->
</ContentTypes>

The problem i have is that when a list is provisioned the folder based content type is always second in the list, and as a result is never the default in the list, the only way i can make it default is to remove all the other content type declarations which sort of defeats the object of having multiple content types. Is this ordering because of the way the list is provisioned or am i missing something tucked away deep in the SDK, any help gratefully accepted


Solution

  • Using a FeatureReceiver you can set the lists RootFolder.UniqueContentTypeOrder to an ordered list of ContentTypes which will then determine to Button order.

    You can also leave out ContentTypes which you don't want to be available even though they are defined in the list. It's common to combine this with an event receiver which sets the button order (UniqueContentTypeOrder) of folders added, to guide people into a certain structure like only folders at the top level and no nested folders (or only x levels deep) or what you like.