Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ramework into pr975
  • Loading branch information
jansenbe committed Feb 1, 2024
2 parents 15ba9eb + b9ee2ee commit c26823f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/lib/PnP.Framework/Modernization/Extensions/WebExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ public static partial class WebExtensions
/// <param name="web">Web to get the pages from</param>
/// <param name="pageNameStartsWith">Filter to get all pages starting with</param>
/// <param name="folder"></param>
/// <returns>A list of pages (ListItem intances)</returns>
/// <returns>A list of pages (ListItem instances)</returns>
public static ListItemCollection GetPages(this Web web, string pageNameStartsWith = null, string folder = null)
{
// Get pages library
ListCollection listCollection = web.Lists;
listCollection.EnsureProperties(coll => coll.Include(li => li.BaseTemplate, li => li.RootFolder));
var sitePagesLibrary = listCollection.Where(p => p.BaseTemplate == (int)ListTemplateType.WebPageLibrary).FirstOrDefault();
listCollection.EnsureProperties(coll => coll.Include(li => li.BaseTemplate, li => li.RootFolder, li => li.ListItemEntityTypeFullName));
var sitePagesLibrary = listCollection
.Where(p => p.BaseTemplate == (int)ListTemplateType.WebPageLibrary)
// Verify this is the "real" pages library, sites supporting Viva Connections have a second pages library (named Announcements) used to
// store Viva Connections announcements
.Where(p => p.IsPropertyAvailable(p => p.ListItemEntityTypeFullName) && p.ListItemEntityTypeFullName == "SP.Data.SitePagesItem")
.FirstOrDefault();
if (sitePagesLibrary != null)
{
CamlQuery query = null;
Expand Down Expand Up @@ -67,7 +72,7 @@ public static ListItemCollection GetPages(this Web web, string pageNameStartsWit
/// <param name="webRelativeListName">Web relative URL of the list (e.g. SiteAssets)</param>
/// <param name="pageNameStartsWith">Filter to get all pages starting with</param>
/// <param name="folder">Folder to search in</param>
/// <returns>A list of pages (ListItem intances)</returns>
/// <returns>A list of pages (ListItem instances)</returns>
public static ListItemCollection GetPagesFromList(this Web web, string webRelativeListName, string pageNameStartsWith = null, string folder = null)
{
// Load selected list
Expand Down Expand Up @@ -136,7 +141,7 @@ public static ListItemCollection GetPagesFromList(this Web web, string webRelati
/// <param name="webRelativeListName">Web relative URL of the blog list (e.g. Posts)</param>
/// <param name="pageNameStartsWith">Filter to get all blogs starting with</param>
/// <param name="folder">Folder to search in</param>
/// <returns>A list of pages (ListItem intances)</returns>
/// <returns>A list of pages (ListItem instances)</returns>
public static ListItemCollection GetBlogsFromList(this Web web, string webRelativeListName, string pageNameStartsWith = null, string folder = null)
{
// Load selected list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplat
try
{
ListCollection listCollection = web.Lists;
listCollection.EnsureProperties(coll => coll.Include(li => li.BaseTemplate, li => li.RootFolder));
sitePagesLibrary = listCollection.Where(p => p.BaseTemplate == (int)ListTemplateType.WebPageLibrary).FirstOrDefault();
listCollection.EnsureProperties(coll => coll.Include(li => li.BaseTemplate, li => li.RootFolder, li => li.ListItemEntityTypeFullName));
sitePagesLibrary = listCollection
.Where(p => p.BaseTemplate == (int)ListTemplateType.WebPageLibrary)
// Verify this is the "real" pages library, sites supporting Viva Connections have a second pages library (named Announcements) used to
// store Viva Connections announcements
.Where(p => p.IsPropertyAvailable(p => p.ListItemEntityTypeFullName) && p.ListItemEntityTypeFullName == "SP.Data.SitePagesItem")
.FirstOrDefault();
}
catch
{
Expand Down

0 comments on commit c26823f

Please sign in to comment.