Share via


PublishingWeb.IsInheritingAvailableWebTemplates Property

Gets a Boolean value that indicates whether the available Web templates that are returned by the GetAvailableWebTemplates() method are inherited from the parent PublishingWeb.

Namespace:  Microsoft.SharePoint.Publishing
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Syntax

'Declaration
Public ReadOnly Property IsInheritingAvailableWebTemplates As Boolean
    Get
'Usage
Dim instance As PublishingWeb
Dim value As Boolean

value = instance.IsInheritingAvailableWebTemplates
public bool IsInheritingAvailableWebTemplates { get; }

Property Value

Type: System.Boolean
Set to True if the available Web templates for PublishingWeb are inherited from the parent PublishingWeb; otherwise, it is set to False.

Examples

This sample demonstrates setting and saving property values on a publishing Web. Before building and running this sample, verify that Publishing feature has been enabled for the SPWeb, and that the defaultPageFileId is SPFile.UniqueId for the new default page.

[c#]

using SPContentTypeId = Microsoft.SharePoint.SPContentTypeId;
using SPContentType = Microsoft.SharePoint.SPContentType;
using SPSite = Microsoft.SharePoint.SPSite;
using SPFile = Microsoft.SharePoint.SPFile;
using SPWeb = Microsoft.SharePoint.SPWeb;
using PublishingSite = Microsoft.SharePoint.Publishing.PublishingSite;
using PublishingWeb = Microsoft.SharePoint.Publishing.PublishingWeb;
using PageLayoutCollection = Microsoft.SharePoint.Publishing.PageLayoutCollection;
using PageLayout = Microsoft.SharePoint.Publishing.PageLayout;

namespace Microsoft.SDK.SharePointServer.Samples
{
    public static class PublishingWebCodeSamples
    {
        public static void SetPublishingWebProperties(SPWeb web, System.Guid defaultPageFileId)
        {
            // TODO: Replace these variable values and input parameters
            // with your own values.
            string newTitle = "your Title";                     // new PublishingWeb.Title value
            string newDescription = "your Description";         // new PublishingWeb.Description value
            bool resetInheritPageLayouts = true;                // new PublishingWeb.IsInheritingAvailablePageLayouts value
            bool resetInheritWebTemplates = true;               // new PublishingWeb.IsInheritingAvailableWebTemplates value

            // Validate the input parameters.
            if (null == web)
            {
                throw new System.ArgumentNullException("web");
            }

            // Get the PublishingWeb wrapper for the SPWeb 
            // that was passed in.
            PublishingWeb publishingWeb = null;
            if (PublishingWeb.IsPublishingWeb(web))
            {
                publishingWeb = PublishingWeb.GetPublishingWeb(web);
            }
            else
            {
                throw new System.ArgumentException("The SPWeb must be a PublishingWeb", "web");
            }

            //  Retrieve the SPFile.
            SPFile newDefaultPageFile = publishingWeb.Web.GetFile(defaultPageFileId);
            if( (null == newDefaultPageFile) ||
                !newDefaultPageFile.Exists )
            {
                throw new System.ArgumentException(
                    "The Guid does not match an SPFile on the SPWeb",
                    "defaultPageFileId");
            }

            // Set new values on the PublishingWeb.
            publishingWeb.Title = newTitle;
            publishingWeb.Description = newDescription;
            publishingWeb.DefaultPage = newDefaultPageFile;
            if( resetInheritPageLayouts && 
                !publishingWeb.IsInheritingAvailablePageLayouts  &&
                !publishingWeb.IsRoot)
            {
                publishingWeb.InheritAvailablePageLayouts();
                System.Diagnostics.Debug.Assert(publishingWeb.IsInheritingAvailablePageLayouts);
            }
            if (resetInheritWebTemplates && 
                !publishingWeb.IsInheritingAvailableWebTemplates &&
                !publishingWeb.IsRoot)
            {
                publishingWeb.InheritAvailableWebTemplates();
                System.Diagnostics.Debug.Assert(publishingWeb.IsInheritingAvailableWebTemplates);
            }

            // Save the new values on the PublishingWeb.
            publishingWeb.Update();
        }
    }
}

See Also

Reference

PublishingWeb Class

PublishingWeb Members

Microsoft.SharePoint.Publishing Namespace

[P:Microsoft.SharePoint.Publishing.PublishingWeb.IsAllowingAllWebTemplatesM:Microsoft.SharePoint.Publishing.PublishingWeb.GetAvailableWebTemplates(System.UInt32)]

[M:Microsoft.SharePoint.Publishing.PublishingWeb.GetAvailableCrossLanguageWebTemplatesM:Microsoft.SharePoint.Publishing.PublishingWeb.AllowAllWebTemplates(System.Boolean)]

[M:Microsoft.SharePoint.Publishing.PublishingWeb.InheritAvailableWebTemplatesM:Microsoft.SharePoint.Publishing.PublishingWeb.SetAvailableWebTemplates(System.Collections.ObjectModel.Collection{Microsoft.SharePoint.SPWebTemplate},System.UInt32,System.Boolean)]

SetAvailableCrossLanguageWebTemplates

Update