SPWeb.GetAvailableWebTemplates 方法 (UInt32, Boolean)

Gets the site templates that are available for creating subsites beneath the website, based on the specified locale identifier (ID) and whether to include language-neutral site templates.

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Function GetAvailableWebTemplates ( _
    lcid As UInteger, _
    doIncludeCrossLanguage As Boolean _
) As SPWebTemplateCollection
用法
Dim instance As SPWeb
Dim lcid As UInteger
Dim doIncludeCrossLanguage As Boolean
Dim returnValue As SPWebTemplateCollection

returnValue = instance.GetAvailableWebTemplates(lcid, _
    doIncludeCrossLanguage)
public SPWebTemplateCollection GetAvailableWebTemplates(
    uint lcid,
    bool doIncludeCrossLanguage
)

参数

  • lcid
    类型:System.UInt32

    The locale ID of the web templates to be retrieved.

  • doIncludeCrossLanguage
    类型:System.Boolean

    true to include language-neutral site templates; otherwise, false.

返回值

类型:Microsoft.SharePoint.SPWebTemplateCollection
The web templates.

备注

In some instances, the specified custom site definition is not found because the custom site definition is not yet in the cache. This occurs when the following steps are made to create a new site collection based on the custom site definition:

  1. Add a solution that consists of site templates and features.

  2. Create a web application.

  3. Deploy the solution, including deployment of the application DLLs to the bin directory of the newly created web application.

  4. Create a new site collection that is based on the custom site definition that was deployed to the web application.

When this sequence occurs, steps 1, 2, and 3 work as expected, but when step 4 is performed, the application does not find the site definition for the newly deployed site. The issue arises because site templates are cached when a new web application is created.

There are four ways to work around this issue.

  1. Perform the first three steps, as described above, run the application, and then perform step 4. This restarts the process and allows the Web application to locate the deployed custom site definition.

  2. Create a console application that creates a site collection using the template for the custom site definition. Then, call the sequence of four steps that are listed above; however, when you come to step 4 (create site collection), load the console executable program that you created in a different process and allow it to complete step 4.

  3. Use the SharePoint Management Shell in the code itself. The web application is able to locate the newly deployed custom site definition.

  4. Add and deploy the solution manually by using the SharePoint UI, or by using the SharePoint Management Shell.

另请参阅

引用

SPWeb 类

SPWeb 成员

GetAvailableWebTemplates 重载

Microsoft.SharePoint 命名空间