Class NavigationExtensions
This class holds navigation related methods
Inheritance
System.Object
NavigationExtensions
Assembly: PnP.Framework.dll
Syntax
public static class NavigationExtensions : object
Methods
Adds custom action to a site collection. If the CustomAction exists the item will be updated.
Setting CustomActionEntity.Remove == true will delete the CustomAction.
Declaration
public static bool AddCustomAction(this Site site, CustomActionEntity customAction)
Parameters
Site
site
Site collection to be processed
|
CustomActionEntity
customAction
Information about the custom action be added or deleted
|
Returns
System.Boolean
True if action was successfull
|
Adds custom action to a web. If the CustomAction exists the item will be updated.
Setting CustomActionEntity.Remove == true will delete the CustomAction.
Declaration
public static bool AddCustomAction(this Web web, CustomActionEntity customAction)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
CustomActionEntity
customAction
Information about the custom action be added or deleted
|
Returns
System.Boolean
True if action was successfull
|
Examples
var editAction = new CustomActionEntity()
{
Title = "Edit Site Classification",
Description = "Manage business impact information for site collection or sub sites.",
Sequence = 1000,
Group = "SiteActions",
Location = "Microsoft.SharePoint.StandardMenu",
Url = EditFormUrl,
ImageUrl = EditFormImageUrl,
Rights = new BasePermissions(),
};
editAction.Rights.Set(PermissionKind.ManageWeb);
web.AddCustomAction(editAction);
Add a node to quick launch, top navigation bar or search navigation. The node will be added as the last node in the
collection.
Declaration
public static NavigationNode AddNavigationNode(this Web web, string nodeTitle, Uri nodeUri, string parentNodeTitle, NavigationType navigationType, bool isExternal = false, bool asLastNode = true, string l1ParentNodeTitle = null)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
System.String
nodeTitle
the title of node to add
|
Uri
nodeUri
the URL of node to add
|
System.String
parentNodeTitle
if string.Empty, then will add this node as top level node. Contains the title of the immediate parent node, for third level nodes, providing l1ParentNodeTitle is required.
|
NavigationType
navigationType
the type of navigation, quick launch, top navigation or search navigation
|
System.Boolean
isExternal
true if the link is an external link
|
System.Boolean
asLastNode
true if the link should be added as the last node of the collection
|
System.String
l1ParentNodeTitle
title of the first level parent, if this node is a third level navigation node
|
Returns
NavigationNode
Newly added NavigationNode
|
Utility method to check particular custom action already exists on the web
Declaration
public static bool CustomActionExists(this Site site, string name)
Parameters
Site
site
Site to process
|
System.String
name
Name of the custom action
|
Returns
Utility method to check particular custom action already exists on the web
Declaration
public static bool CustomActionExists(this Web web, string name)
Parameters
Web
web
Web to process
|
System.String
name
Name of the custom action
|
Returns
Deletes all Navigation Nodes from a given navigation
Declaration
public static void DeleteAllNavigationNodes(this Web web, NavigationType navigationType)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
NavigationType
navigationType
The type of navigation to support
|
Declaration
public static void DeleteCustomAction(this Site site, Guid id)
Parameters
Site
site
The site to process
|
Guid
id
The id of the action to remove.
GetCustomActions
|
Declaration
public static void DeleteCustomAction(this Web web, Guid id)
Parameters
Web
web
The web to process
|
Guid
id
The id of the action to remove.
GetCustomActions
|
Deletes a navigation node from the quickLaunch or top navigation bar
Declaration
public static void DeleteNavigationNode(this Web web, string nodeTitle, string parentNodeTitle, NavigationType navigationType)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
System.String
nodeTitle
the title of node to delete
|
System.String
parentNodeTitle
if string.Empty, then will delete this node as top level node
|
NavigationType
navigationType
the type of navigation, quick launch, top navigation or search navigation
|
Returns all custom actions in a web
Declaration
public static IEnumerable<UserCustomAction> GetCustomActions(this Site site, params Expression<Func<UserCustomAction, object>>[] expressions)
Parameters
Site
site
The site to process
|
Expression<Func<UserCustomAction, System.Object>>[]
expressions
List of lambda expressions of properties to load when retrieving the object
|
Returns
IEnumerable<UserCustomAction>
Returns all custom actions
|
Returns all custom actions in a web
Declaration
public static IEnumerable<UserCustomAction> GetCustomActions(this Web web, params Expression<Func<UserCustomAction, object>>[] expressions)
Parameters
Web
web
The web to process
|
Expression<Func<UserCustomAction, System.Object>>[]
expressions
List of lambda expressions of properties to load when retrieving the object
|
Returns
IEnumerable<UserCustomAction>
Returns all custom actions
|
Returns an editable version of the Global Navigation TermSet for a web site
Declaration
public static NavigationTermSet GetEditableNavigationTermSet(this Web web, ManagedNavigationKind navigationKind)
Parameters
Web
web
The target web.
|
ManagedNavigationKind
navigationKind
Declares whether to look for Current or Global Navigation
|
Returns
NavigationTermSet
The editable Global Navigation TermSet
|
Returns the navigation settings for the selected web
Declaration
public static AreaNavigationEntity GetNavigationSettings(this Web web)
Parameters
Returns
Determines whether the current Web has the managed navigation enabled
Declaration
public static bool IsManagedNavigationEnabled(this Web web, ManagedNavigationKind navigationKind)
Parameters
Returns
System.Boolean
A boolean result of the test.
|
Loads the search navigation nodes
Declaration
public static NavigationNodeCollection LoadSearchNavigation(this Web web)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
Returns
NavigationNodeCollection
Collection of NavigationNode instances
|
Updates the navigation inheritance setting
Declaration
public static void UpdateNavigationInheritance(this Web web, bool inheritNavigation)
Parameters
Web
web
Site to be processed - can be root web or sub site
|
System.Boolean
inheritNavigation
boolean indicating if navigation inheritance is needed or not
|
Updates navigation settings for the current web
Declaration
public static void UpdateNavigationSettings(this Web web, AreaNavigationEntity navigationSettings)
Parameters