1
votes

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

3

3 Answers

1
votes

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.

1
votes

Check the property bag. The list you're working on probably has a property called "vti_contenttypeorder", with the content type id's in the order they will show up when you go reordering them through the UI.

0
votes

...building on @Renan answer - set your default Content Type declaratively. Create a module, name it Property bags and add it to the web scope feature containing your list instance. The Elements.xml should contain the following:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <PropertyBag Url="<!--URL of your list instance here-->" ParentType="Folder" RootWebOnly="FALSE" AlwaysCreateFolder="TRUE" xmlns="http://schemas.microsoft.com/sharepoint/">
    <Property Name="vti_contenttypeorder" Value="<!--Your custom Content Type ID here-->" Type="string" /> 
  </PropertyBag>
</Elements>