views:

722

answers:

1

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

+1  A: 

Hi Matt

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.

Per Jakobsen
thanks per, i think ive probably spent way too long battling with this from a purely declarative stance. Im aware of how i can get this to work otherwise but part of me really wants to understand why content types are ordinal unless one of them is based upon the folder content type, and also, why it always appears second in the list no matter what other content types appear after it
Matt
+1 for the sound advice, still hoping for an insight into how its done declaratively
Matt
ok, im marking as answer, a dig around in the assemblies shows that much of this work is either in obfuscated code or in SPrequest calls to owssvr.dll the upshot is that the ordering, as far as i can see, is not affected by anything declarative.
Matt