PublishingWeb.GetPublishingPages PublishingWeb.GetPublishingPages PublishingWeb.GetPublishingPages Method

Definition

Overloads

GetPublishingPages() GetPublishingPages() GetPublishingPages()

Gets a collection of PublishingPage objects contained in this PublishingWeb object.

GetPublishingPages(SPQuery) GetPublishingPages(SPQuery) GetPublishingPages(SPQuery)

Gets a collection of PublishingPage objects contained in this PublishingWeb object.

GetPublishingPages(String) GetPublishingPages(String) GetPublishingPages(String)

Gets a collection of PublishingPage objects contained in this PublishingWeb object.

GetPublishingPages(UInt32) GetPublishingPages(UInt32) GetPublishingPages(UInt32)

Gets a collection of PublishingPage objects contained in this PublishingWeb object.

GetPublishingPages(String, UInt32) GetPublishingPages(String, UInt32) GetPublishingPages(String, UInt32)

Gets a collection of PublishingPage objects that are contained in this PublishingWeb object.

GetPublishingPages() GetPublishingPages() GetPublishingPages()

Gets a collection of PublishingPage objects contained in this PublishingWeb object.

public:
 Microsoft::SharePoint::Publishing::PublishingPageCollection ^ GetPublishingPages();
public Microsoft.SharePoint.Publishing.PublishingPageCollection GetPublishingPages ();
Public Function GetPublishingPages () As PublishingPageCollection
Returns
Exceptions

The site is not valid. The Pages document library is missing.

Examples

<p>This example creates a new <strong>PublishingPage</strong> in a <strong>PublishingWeb</strong>.</p>
<p>Before compiling and running this example, verify that an <strong>SPWeb</strong> that is a publishing Web exists and is passed in as the Web parameter. The <strong>PageLayout</strong> to use for creating the page must also be passed in.</p>
<pre><code>using SPWeb = Microsoft.SharePoint.SPWeb;

using PublishingWeb = Microsoft.SharePoint.Publishing.PublishingWeb; using PageLayout = Microsoft.SharePoint.Publishing.PageLayout; using PublishingPageCollection = Microsoft.SharePoint.Publishing.PublishingPageCollection; using PublishingPage = Microsoft.SharePoint.Publishing.PublishingPage;

namespace Microsoft.SDK.SharePointServer.Samples { public static class PublishingPageCollectionCodeSamples {

    public static void CreateNewPage( SPWeb web, PageLayout pageLayout )
    {

// Replace these variable values with your own values. string newPageName = "Contoso.aspx"; // the URL name of the new page string checkInComment = "Your check in comments"; // the comment to set when the page is checked in

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

// 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"); }

// Create the new page in the PublishingWeb. PublishingPageCollection pages = publishingWeb.GetPublishingPages(); PublishingPage newPage = pages.Add(newPageName, pageLayout);

// Check in the new page so that others can work on it. newPage.CheckIn(checkInComment);
} } }

Imports SPWeb = Microsoft.SharePoint.SPWeb
Imports PublishingWeb = Microsoft.SharePoint.Publishing.PublishingWeb
Imports PageLayout = Microsoft.SharePoint.Publishing.PageLayout
Imports PublishingPageCollection = Microsoft.SharePoint.Publishing.PublishingPageCollection
Imports PublishingPage = Microsoft.SharePoint.Publishing.PublishingPage

Namespace Microsoft.SDK.SharePointServer.Samples
    Public NotInheritable Class PublishingPageCollectionCodeSamples


        Private Sub New()
        End Sub
        Public Shared Sub CreateNewPage(ByVal web As SPWeb, ByVal pageLayout As PageLayout)
' Replace these variable values with your own values.
Dim newPageName As String = "Contoso.aspx" ' the URL name of the new page
Dim checkInComment As String = "Your check in comments" ' the comment to set when the page is checked in

' Validate the input parameters.
If Nothing Is web Then
    Throw New System.ArgumentNullException("web")
End If
If Nothing Is pageLayout Then
    Throw New System.ArgumentNullException("pageLayout")
End If

' Get the PublishingWeb wrapper for the SPWeb that was passed in.
Dim publishingWeb As PublishingWeb = Nothing
If PublishingWeb.IsPublishingWeb(web) Then
    publishingWeb = PublishingWeb.GetPublishingWeb(web)
Else
    Throw New System.ArgumentException("The SPWeb must be a PublishingWeb", "web")
End If

' Create the new page in the PublishingWeb.
Dim pages As PublishingPageCollection = publishingWeb.GetPublishingPages()
Dim newPage As PublishingPage = pages.Add(newPageName, pageLayout)

' Check in the new page so that others can work on it.
newPage.CheckIn(checkInComment)
        End Sub
    End Class
End Namespace

Remarks

This method gets all PublishingPage objects for this PublishingWeb object. For a large collection, you can use data paging with the other Microsoft.SharePoint.Publishing.PublishingWeb.GetPublishingPage method(s) to retrieve this collection in smaller subsets.

To apply sorting or filtering, use a Microsoft.SharePoint.Publishing.PublishingWeb.GetPublishingPages(Microsoft.SharePoint.SPQuery method that takes SPQuery, String, or System.String.UInt32 to create a Collaborative Application Markup Language (CAML) query that specifies sorting and collection membership requirements.

GetPublishingPages(SPQuery) GetPublishingPages(SPQuery) GetPublishingPages(SPQuery)

Gets a collection of PublishingPage objects contained in this PublishingWeb object.

public:
 Microsoft::SharePoint::Publishing::PublishingPageCollection ^ GetPublishingPages(Microsoft::SharePoint::SPQuery ^ query);
public Microsoft.SharePoint.Publishing.PublishingPageCollection GetPublishingPages (Microsoft.SharePoint.SPQuery query);
Public Function GetPublishingPages (query As SPQuery) As PublishingPageCollection
Parameters
query
SPQuery SPQuery SPQuery

The SPQuery object to use when retrieving the collection.

Returns
Exceptions

The collection retrieval failed. The CAML query may be invalid.

The site is not valid. The Pages document library is missing.

The value cannot be set to a null reference (Nothing in Visual Basic).

Examples

<p>You can use the CAML <strong>&lt;</strong>OrderBy<strong>&gt;</strong> tag to sort the collection. For example, to order a collection in ascending order based on title, use this CAML query.</p>
<pre><code>&amp;lt;br/&amp;gt;

&lt;OrderBy&gt; &lt;FieldRef Name="Title" Ascending="TRUE"&gt; &lt;/FieldRef&gt; &lt;/OrderBy&gt;

You can use the CAML <Where> tag to filter the collection. For example, to filter a collection based on title matching the value "abc", use this CAML query.

&lt;br/&gt;
&lt;Where&gt;
&lt;Eq&gt;
&lt;FieldRef Name="Title"&gt;
&lt;/FieldRef&gt;
&lt;Value Type="Text"&gt;abc&lt;/Value&gt;
&lt;/Eq&gt;
&lt;/Where&gt;

Remarks

Set the RowLimit property on the query parameter to indicate the paging data size.

Set the Query property on the query parameter to indicate the Collaborative Application Markup Language (CAML) query to use when retrieving the collection.

GetPublishingPages(String) GetPublishingPages(String) GetPublishingPages(String)

Gets a collection of PublishingPage objects contained in this PublishingWeb object.

public:
 Microsoft::SharePoint::Publishing::PublishingPageCollection ^ GetPublishingPages(System::String ^ camlQueryXml);
public Microsoft.SharePoint.Publishing.PublishingPageCollection GetPublishingPages (string camlQueryXml);
Public Function GetPublishingPages (camlQueryXml As String) As PublishingPageCollection
Parameters
camlQueryXml
String String String

The CAML query XML parameter that is used to determine the sort order, filtering, and other properties for the PublishingPageCollection objects that have been retrieved.

Returns

A PublishingPageCollection collection containing PublishingPage objects in this PublishingWeb, based on the camQueryXml argument.

Exceptions

The camlQueryXml parameter is a null reference (Nothing in Visual Basic).

The collection retrieval failed. The CAML query may not be valid.

The site is not valid. The Pages document library is missing.

Examples

<p>You can use the CAML <strong>&lt;</strong>OrderBy<strong>&gt;</strong> tag to sort the collection. For example, to order a collection in ascending order based on title, use this CAML query.</p>
<pre><code>&amp;lt;br/&amp;gt;

&lt;OrderBy&gt; &lt;FieldRef Name="Title" Ascending="TRUE"&gt; &lt;/FieldRef&gt; &lt;/OrderBy&gt; &lt;br/&gt;

You can use the CAML <Where> tag to filter the collection. For example, to filter a collection based on the title matching the value "abc", use this CAML query.

&lt;br/&gt;
&lt;Where&gt;
&lt;Eq&gt;
&lt;FieldRef Name="Title"&gt;
&lt;/FieldRef&gt;
&lt;Value Type="Text"&gt;abc&lt;/Value&gt;
&lt;/Eq&gt;
&lt;/Where&gt;

Remarks

This method gets PublishingPage objects that are contained in this PublishingWeb class, based on the query information provided in the camlQueryXml argument. No item (row) limit applies to the collection; that is, no data paging occurs.

The camlQueryXml argument passed in this method is equivalent to the Query property.

GetPublishingPages(UInt32) GetPublishingPages(UInt32) GetPublishingPages(UInt32)

Gets a collection of PublishingPage objects contained in this PublishingWeb object.

public:
 Microsoft::SharePoint::Publishing::PublishingPageCollection ^ GetPublishingPages(System::UInt32 rowLimit);
public Microsoft.SharePoint.Publishing.PublishingPageCollection GetPublishingPages (uint rowLimit);
Public Function GetPublishingPages (rowLimit As UInteger) As PublishingPageCollection
Parameters
rowLimit
UInt32 UInt32 UInt32

The maximum number of items (rows) to return each time the PublishingPageCollection collection is retrieved.

Returns

A PublishingPageCollection collection containing the first nPublishingPage objects in the PublishingWeb where n is the rowLimit value

Exceptions

The site is not valid. The Pages document library is missing.

Remarks

The rowLimit argument passed in this method is equivalent to the RowLimit property.

You can use the Microsoft.SharePoint.Publishing.PublishingPageCollection`1.QueryNext method of the returned collection to retrieve the next n items in the collection where n is the rowLimit argument value. The Microsoft.SharePoint.Publishing.PublishingPageCollection.RowLimit property of the returned collection returns the rowLimit value set here.

If the rowLimit value is 0, then all the PublishingPage objects for the PublishingWeb class are retrieved when the PublishingPageCollection collection is created. The same is true if the rowLimit exceeds the maximum number of PublishingPage objects in the PublishingWeb class.

The PublishingPageCollection that is returned has no specific sorting or filtering applied.

GetPublishingPages(String, UInt32) GetPublishingPages(String, UInt32) GetPublishingPages(String, UInt32)

Gets a collection of PublishingPage objects that are contained in this PublishingWeb object.

public:
 Microsoft::SharePoint::Publishing::PublishingPageCollection ^ GetPublishingPages(System::String ^ camlQueryXml, System::UInt32 rowLimit);
public Microsoft.SharePoint.Publishing.PublishingPageCollection GetPublishingPages (string camlQueryXml, uint rowLimit);
Public Function GetPublishingPages (camlQueryXml As String, rowLimit As UInteger) As PublishingPageCollection
Parameters
camlQueryXml
String String String

The CAML query XML that is used to determine sort order, filtering, and other properties for the PublishingPageCollection collection.

rowLimit
UInt32 UInt32 UInt32

The maximum number of items (rows) to return each time the PublishingPageCollection is retrieved.

Returns

A PublishingPageCollection containing the first nPublishingPage objects in this Microsoft.SharePoint.Publishing.PublishingWebclass, where n is the rowLimit value sorted and filtered based on the camlQueryXml argument.

Exceptions

The collection retrieval failed. The CAML query may be invalid.

The site is not valid. The Pages document library is missing.

Examples

<p>You can use the CAML <strong>&lt;</strong>OrderBy<strong>&gt;</strong> tag to sort the collection. For example, to order a collection in ascending order based on title, use this CAML query.</p>
<pre><code>&amp;lt;br/&amp;gt;

&lt;OrderBy&gt; &lt;FieldRef Name="Title" Ascending="TRUE"&gt; &lt;/FieldRef&gt; &lt;/OrderBy&gt; &lt;br/&gt;

You can use the CAML <Where> tag to filter the collection. For example, to filter a collection based on the title matching the value "abc", use this CAML query.

&lt;br/&gt;
&lt;Where&gt;
&lt;Eq&gt;
&lt;FieldRef Name="Title"&gt;
&lt;/FieldRef&gt;
&lt;Value Type="Text"&gt;abc&lt;/Value&gt;
&lt;/Eq&gt;
&lt;/Where&gt;

Remarks

This method gets PublishingPage objects for this PublishingWeb class based on the query information provided in the camlQueryXml argument. It returns only the first nPublishingPage objects in this PublishingWeb where n is the rowLimit value.

The camlQueryXml argument passed by this method is equivalent to the Query property in Microsoft SharePoint Foundation.The rowLimit argument is equivalent to the RowLimit property in SharePoint Foundation.

You can use the Microsoft.SharePoint.Publishing.PublishingPageCollection`1.QueryNext method of the returned collection to retrieve the next n items in the collection where n is the rowLimit argument value. The Microsoft.SharePoint.Publishing.PublishingPageCollection`1.QueryNext property returns the rowLimit value set here.

If the rowLimit value is zero, then all PublishingPage objects for the PublishingWeb class are retrieved when the PublishingPageCollection is created. The same is true if the rowLimit exceeds the maximum number of PublishingPage objects in the PublishingWeb class.

Applies to