2011-03-28 71 views
2

我對我所啓封並添加列的內容類型,「文件夾」的站點。現在,我想這個內容類型添加到文檔庫,但我沒有將它添加在文檔庫設置選項 - >添加從現有網站內容類型。我沒有看到在組下拉菜單中的「文件夾內容類型」。另外,如果我移動內容類型到另一個組,它在該下拉顯示出來,它仍然沒有出現。有什麼我需要做的,使這個內容類型的選擇。我的文檔庫,或選擇哪些內容類型組是一個網站可以使用的地方嗎?不能利用文件夾的內容類型在SharePoint 2007中

非常感謝

+1

看一看使用SharePoint管理網站。它會明確告訴你文件夾內容類型是否已更改。 – Nat 2011-03-28 20:43:08

回答

2

如果你創建自己的內容類型,並在發佈/啓動到SharePoint,那麼就應該是可供您添加到文檔庫。只要確保您的文檔庫已配置爲支持內容類型。

在文檔庫設置的高級設置部分,在Allow management of content types?下選擇Yes然後按照原樣繼續。 設置 - >添加從現有網站內容類型..

您可以使用一個控制檯應用程序(REF MSDN)內容類型添加到列表中的網站。它還爲您提供有關當前事物狀態的有用信息。

class Program { 
    static void Main(string[] args) { 
     using (SPSite siteCollection = new SPSite("http://YOUR_SPSITE")) { 
      using (SPWeb site = siteCollection.OpenWeb() { 

       // Get a content type. 
       SPContentType ct = site.AvailableContentTypes["YOUR_CONTENT_NAME"]; 

       // The content type was found. 
       if (ct != null) 
        // Get a list. 
        try { 
         SPList list = site.Lists["YOUR_DOCUMENT_LIBRARY_NAME"]; // Throws exception if does not exist. 

         // Make sure the list accepts content types. 
         list.ContentTypesEnabled = true; 

         // Add the content type to the list. 
         if (!list.IsContentTypeAllowed(ct)) 
          Console.WriteLine("The {0} content type is not allowed on the {1} list", 
               ct.Name, list.Title); 
         else if (list.ContentTypes[ct.Name] != null) 
          Console.WriteLine("The content type name {0} is already in use on the {1} list", 
               ct.Name, list.Title); 
         else 
          list.ContentTypes.Add(ct); 
        } 
        catch (ArgumentException ex) // No list is found.       
        { 
         Console.WriteLine("The list does not exist."); 
        } 
       else // No content type is found. 
        Console.WriteLine("The content type is not available in this site."); 
      } 
     } 
     Console.Write("\nPress ENTER to continue..."); 
     Console.ReadLine(); 
    } 
} 
相關問題