Search code examples
sharepointsharepoint-2007moss

Adding a Content Type to all Document Libraries


We have hundreds of document libraries, spread all throughout various site collections in a MOSS 2007 SharePoint site.

The problem is, that I want to add Content Type to show up in addition to the "New Document" and "New Folder" content types: the "Link to a Document" content type (0x01010A). This new content type should should up for all existing and new document libraries.


What I've tried:

I thought that I would be able to add the following to a schema.xml somewhere inside the <ContentTypes></ContentTypes> node:

<!-- Link to Document Content Type -->
<ContentTypeRef ID="0x01010A" />

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\Publishing\Pages\schema.xml

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\DocumentLibrary\DocLib\schema.xml

This seems to have added the content type to the libraries OK, but it doesn't show up under the New menu (still just displays the "Document" and "Folder" content types). If I set "Allow management of content types?" to "Yes" then it shows up.

tl;dr

Q: How do I add the "Link to a Document" content type to all document libraries and have it show up in the New menu?


Solution

  • After doing some more investigation, I found out that by changing ..\12\TEMPLATE\FEATURES\DocumentLibrary\DocLib\schema.xml I could add the Link to a Document content type to all NEW document libraries. Changing the schema.xml and then doing an IISRESET did not change existing libraries.

    In order to do this, the beginning of my schema.xml looked something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <List xmlns:ows="Microsoft SharePoint" Title="$Resources:shareddocuments_Title;" Direction="$Resources:Direction;" Url="Shared Documents" BaseType="1" EnableContentTypes="TRUE">
      <!-- Link to Document Content Type - Added EnableContentTypes="TRUE" -->
      <MetaData>
        <ContentTypes>
          <ContentTypeRef ID="0x0101">
            <Folder TargetName="Forms/Document" />
          </ContentTypeRef>
          <ContentTypeRef ID="0x0120" />
          <!-- Link to Document Content Type -->
          <ContentTypeRef ID="0x01010A" />
        </ContentTypes>
    

    Since this didn't change existing document libraries, I will need to write a console application that uses the code specified in the other two answers to update each library.