Aug 26, 2009

Default Content Types - do not touch!

Content Types are a very powerful means of distributing eg. document templates through the whole Site Collection. And if used in a wrong though possible way, they may turn out to be overpowering even.

There was this issue of distributing the company word template to each and every document library in a site collection with already dozens of sites and libraries in it. A custom content type requires a lot of hand work before it is in use in each of the libraries. But since there is a default document content type, why not change the template it uses?

The default Document Content Type is in fact a sort of pseudo top class that doesn't really contain information about templates. The actual templates are defined in site and list definitions, in site definition and site collection onet.xml files. The blank default document templates referred to in the onet.xml file are in the SharePoint HIVE. Theoretically you could replace these files with you're own, but that's a no-no too.

If you happen to try out this in itself easy looking and appealing scenario of modifying the default document type, you will notice that it gives a log of warnings after making the change and it makes you believe that no change really took place, but it actually does seem to work when you go to a document library and click New to create a new deafult type document. The document uses the template that was set in the document type settings.

So what's all this fuss about then? The next time you create a new document library anywhere in the site collection, you will find that you have lost the possibility to change the default document type of the library. There is no more a drop-down with word, excel powerpoint, basic page etc. choice to make. The default document type template overrides this very functionality of the document libraries. It does not affect the use of custom content types, though.

Fortunately this doesn't create a catastrophe and is easy to change back - the same way the situation was first created. You only need to go to the Advanced settings of the Document Content Type and clear out the text box showing the template file information, and save the settings. It gives the same error log, but saves the day.

Thus the conclusions are:
1) do not modify default content types, stick to making your own ones
2) if you want a modified library with modified document content types, either make the modifications to one library and save it as template, or - even better - make your own list definition and/or site definition solution package

No comments: