Click to Rate and Give Feedback
Community Content
In this section
Statistics Annotations (2)
Collapse All/Expand All Collapse All
This page is specific to
The 2007 product release

Other versions are also available for the following:
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.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
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker