3.5. Microsoft.SharePoint.Publishing Namespace

Before diving into building WCM solutions, it is good to have a broad view of the key Publishing APIs provided by the Microsoft.SharePoint.Publishing namespace.

The Microsoft.SharePoint.Publishing namespace provides the cores classes and can be thought of as the infrastructure plumbing for working within Publishing sites. Commonly used classes within this namespace are described in the following table:

ClassDescription
Microsoft.SharePoint.Publishing.PublishingSiteProvides access to Publishing Features on a SPSite object.
Microsoft.SharePoint.Publishing.PublishingWebProvides access to Publishing Features on a SPWeb object — e.g., accessing the pages collection, accessing other objects in the hierarchy, or executing queries directly.
Microsoft.SharePoint.Publishing.PublishingPageProvides access to Publishing Features on a SPListItem object. A page is an extended SPList object.

The code in Listing 3-1 demonstrates how to enumerate a list of sites in the current site collection within a Web control.

Example 3-1. Enumerating Publishing sites
using System; using System.ComponentModel; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.SharePoint; using Microsoft.SharePoint.Publishing; namespace EnumerateSites { public class EnumerateSitesInSiteCollection : WebControl { protected void ListWebs (PublishingWeb pubWeb, HtmlTextWriter output) { output.Write(string.Format("<A href=\"{0}\">{1}</A>", pubWeb.Url, ...

Get Professional SharePoint® 2007 Web Content Management Development: Building Publishing Sites with Office SharePoint Server 2007 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.