My new blog present here.

Featured Post

Insights into Sitecore Search: A Definitive Introduction

A key component of digital experience management is effective information retrieval. A simplified approach is required for websites, applications, and platforms containing a lot of material so that consumers can easily get the data they require. This need is met by Sitecore, a well-known name in the field of digital experience platforms (DXPs), which provides powerful and comprehensive search functionality. We will travel into the realm of Sitecore Search in this article, learning about its capabilities, architecture , and the enormous value it offers both developers and end users. Introduction to Sitecore Search    A headless content discovery platform powered by AI , Sitecore Search enables you to build predictive and custom search experiences across various content sources. To extract and ...

Accessing SharePoint Publishing site Navigation (Global Navigation bar) using C#

Accessing SharePoint Publishing site Navigation (Global Navigation bar) using C#:

With the help of PublishingWeb class (Microsoft.SharePoint.Publishing), we can access different components of Published Web site like Pages document library, Published site navigation bar and etc.
In this example we will access different components of Published site:


using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using System.Web;
using Microsoft.SharePoint.Navigation;
using Microsoft.SharePoint.Publishing;


namespace GetPublishedData
{
class Program
{
static void Main(string[] args)
{

using (SPSite site = new SPSite("http://amitkumarmca04.blogspot.com/"))
{
using (SPWeb web = site.RootWeb)
{
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);

//Display Global Navigation menu items(Home > Site Settings > Modify Navigation)
foreach (Microsoft.SharePoint.Navigation.SPNavigationNode node in publishingWeb.GlobalNavigationNodes)
{

Console.WriteLine(node.Title + " " + node.Url);

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

}
}
}
}
}


Reference: MSDN

Comments

Popular posts from this blog

Sitecore GraphQL Queries

Sitecore Experience Manager Cloud (XM Cloud) Building blocks

Configuring Sitecore Next.js Headless SXA Multisite App in a Sitecore Container