次の方法で共有


Finding a SharePoint List Template Id

There are several ways to find out the ID for a List.  A typical scenario where a list template id is required is querying a list or set of lists using SPSiteDataQuery.  You can find the list template id by looking at the 12\TEMPLATE\FEATURES directory and finding the list in question.  Opening the element manifest for the feature you will notice an attribute named DocumentTemplate, which is the List Template ID or Type which will provide the list template type, also ID for the out of box templates.

 <?xml version="1.0" encoding="utf-8" ?> 
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
  <ListTemplate Name="doclib" Type="101" 
    BaseType="1" OnQuickLaunch="TRUE" SecurityBits="11" 
    Sequence="110" DisplayName="$Resources:core,doclibList;" 
    Description="$Resources:core,doclibList_Desc;" Image="/_layouts/images/itdl.gif" 
    DocumentTemplate="101" /> 
</Elements>

Another method to do this leveraging the UI is to click Site Actions > Create.  The next screen provides a view of all the lists and document libraries that can be created on the site.  If you right click the list and select properties you will be presented the Url Address for the list.  Highlighting and scrolling to the end of the Url you will see a query string variable called ListTemplate.  The value presented is the list template ID.

image

A more dynamic method of finding this information in code is to leverage the object model.  SPWeb has a property called ListTemplates that returns a collection of the lists that can be created on the site.  The SPListTemplate class held in the collection has a property called DocumentTemplate property providing the List Template ID.

 using( SPSite siteCollection = new SPSite("https://moss.litwareinc.com") ) {
  using( SPWeb web = siteCollection.OpenWeb() ) {
    foreach( SPListTemplate template in web.ListTemplates ) {
      Console.WriteLine(template.DocumentTemplate.ToString());
    }
  }
}

Another little known method for getting the ID, at least for those features that are out of the box, is to use the feature GUID, which has a format of OOBFxxx-xxxx-xxxx-xxxx-xxxxxxxxx101.  For example, the listing for a document library is 00BFEA71-E717-4E80-AA17-D0C71B360101.

Comments

  • Anonymous
    August 04, 2008
    PingBack from http://blog.a-foton.ru/2008/08/finding-a-sharepoint-list-template-id/
  • Anonymous
    August 11, 2008
    Entwicklung SharePoint developer bookmarklets Consistent development of Master Pages, Page Layouts and
  • Anonymous
    August 11, 2008
    Entwicklung SharePoint developer bookmarklets Consistent development of Master Pages, Page Layouts and
  • Anonymous
    December 06, 2009
    Can you tell me how can i add a custom menu to the ViewToolbar part of projectcenter webpart.
  • Anonymous
    February 20, 2011
    This is a truly great and helpful list of templates so i very like this– exactly what I was looking for! I listed a blog regarding for powerpoint templates here availabal all types powerpoint templates related to business, medical, technology, sports,  educations, and more others templates. I’m bookmarking this page…. Thanks for putting this together for us!<a href="powerpointtemplatesallrequirements.wordpress.com/">Powerpoint Templates</a>
  • Anonymous
    February 24, 2011
    I came from kindly ion your sites and see this. I very like so look feel.powerpoint-templates-allrequirements.blogspot.com