Compartilhar via


PublishingWeb.GetPublishingPages método

Obtém uma coleção de objetos PublishingPage contida neste objeto de PublishingWeb .

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

Sintaxe

'Declaração
Public Function GetPublishingPages As PublishingPageCollection
'Uso
Dim instance As PublishingWeb
Dim returnValue As PublishingPageCollection

returnValue = instance.GetPublishingPages()
public PublishingPageCollection GetPublishingPages()

Valor retornado

Tipo: Microsoft.SharePoint.Publishing.PublishingPageCollection
Uma coleção de PublishingPageCollection que contém objetos de PublishingPage no objeto PublishingWeb .

Exceções

Exceção Condição
[Microsoft.SharePoint.Publishing.InvalidPublishingWebException]

O site não é válido. A biblioteca de documentos páginas está ausente.

Comentários

Esse método obtém todos os objetos PublishingPage do objeto PublishingWeb . Para uma coleção grande, você pode usar a paginação de dados com os outros métodos de GetPublishingPage() para recuperar essa coleção em subconjuntos menores.

Para aplicar a classificação ou filtragem, use um método [M:Microsoft.SharePoint.Publishing.PublishingWeb.GetPublishingPages(Microsoft.SharePoint.SPQuery] que usa SPQuery, String, ou UInt32 para criar uma consulta CAML Collaborative Application Markup Language () que especifica a classificação e requisitos de participação da coleção.

Exemplos

Este exemplo cria um novo PublishingPage em um PublishingWeb.

Antes de compilar e executar esse exemplo, verifique se um SPWeb é uma Web de publicação existe e é passado como o parâmetro da Web. PageLayout a ser usado para criar a página também deve ser passado.

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

Ver também

Referência

PublishingWeb classe

PublishingWeb membros

GetPublishingPages em sobrecarga

Microsoft.SharePoint.Publishing namespace