Click to Rate and Give Feedback
PublishingWeb Class (Microsoft.SharePoint.Publishing)
The PublishingWeb class provides publishing behavior for an SPWeb instance that supports publishing. This class cannot be inherited.

Namespace: Microsoft.SharePoint.Publishing
Assembly: Microsoft.SharePoint.Publishing (in microsoft.sharepoint.publishing.dll)

Visual Basic (Declaration)
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
Public NotInheritable Class PublishingWeb
Visual Basic (Usage)
Dim instance As PublishingWeb
C#
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
public sealed class PublishingWeb

The PublishingWeb class provides publishing specific behavior for an SPWeb that supports publishing, including access to child PublishingPage and PublishingWeb instances; variations support; navigation settings; PageLayout and Web template restrictions; and Welcome page settings. This class wraps an SPWeb instance that has the publishing feature activated.

This class can be instantiated by using the static GetPublishingWeb method or by retrieving it from a PublishingWebCollection collection.

The PublishingWeb class wraps the SPWeb class. It also directly exposes the underlying SPWeb through the Web property so that additional SPWeb functionality can be easily accessed.

[c#]

// Access the Pages list information without creating a PublishingWeb
// object.
            using (SPSite site = new SPSite("http://myteam/team/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    if (PublishingWeb.IsPublishingWeb(web))
                    {
                        // Get the Id for the Pages list if we 
                        // know that Web is a PublishingWeb.
                        Guid pagesListId = PublishingWeb.GetPagesListId(web);

                        // Get the list by way of the Id.
                        SPList pagesList = web.Lists[pagesListId];

                        // Get the Pages list URL. Note:
                        // PublishingWeb.GetPagesListName(web)
                        // is equivalent to pagesList.RootFolder.Url.
                        string pagesListUrl = PublishingWeb.GetPagesListName(web);
                    }
                    else
                    {
                        // If the SPWeb is not a PublishingWeb, 
                        // then GetPagesListName returns the URL
                        // that would be used by the Pages list 
                        // if the Publishing feature were to be
                        // activated.
                        string pagesListName = PublishingWeb.GetPagesListName(web);
                    }
                }
            }

            // You can also create a PublishingWeb and access
            // the properties from it.
            using (SPSite site = new SPSite("http://myteam/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);

                    // Get the Id for the Pages list.
                    Guid pagesListId = publishingWeb.PagesListId;

                    SPList pagesList = publishingWeb.PagesList;

                    // The PublishingWeb.PagesListName is equivalent 
                    // to PublishingWeb.PagesList.RootFolder.Url.
                    string pagesListUrl = publishingWeb.PagesListName;
                }
            }
System.Object
   Microsoft.SharePoint.Administration.SPAutoSerializingObject
     Microsoft.SharePoint.Administration.SPPersistedObject
       Microsoft.SharePoint.Publishing.CollectionBase
         Microsoft.SharePoint.Publishing.CollectionBase
           Microsoft.SharePoint.Publishing.ListItemBasedReadOnlyCollection
             Microsoft.SharePoint.Publishing.ListItemBasedCollection
               Microsoft.SharePoint.Publishing.QueryBasedCollection
                 Microsoft.SharePoint.Publishing.Fields.HtmlTagValue
                   Microsoft.SharePoint.Publishing.InheritableProperty
                     Microsoft.SharePoint.Publishing.Internal.Administration.Schema.SPList
                       Microsoft.SharePoint.Publishing.Internal.Administration.Schema.SPDocumentLibrary
                         Microsoft.SharePoint.Publishing.Internal.Converters.BaseContentConverter
                           Microsoft.SharePoint.Publishing.Internal.Upgrade.BaseUpgradeAction
                             Microsoft.SharePoint.Publishing.Internal.Upgrade.CmsFieldAndContentTypeUpgradeAction
                               Microsoft.SharePoint.Publishing.Internal.Upgrade.PublishingLayoutsUpgradeAction
                                 Microsoft.SharePoint.Publishing.Internal.Upgrade.PublishingSiteFilesUpgradeAction
                                   Microsoft.SharePoint.Publishing.Internal.WebControls.LevelElementHierarchyData
                                     Microsoft.SharePoint.Publishing.ListItemWrapper
                                       Microsoft.SharePoint.Publishing.DisposableListItemWrapper
                                         Microsoft.SharePoint.Publishing.Administration.JobReportBase
                                          Microsoft.SharePoint.Publishing.PublishingWeb
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker