Create a group page with the native API
- Get an instance of the
PageManager. Like standard pages, group pages are also manipulated by thePageManager. To work with a group page, you need to get an instance of the manager. - Set the parent of the page. You can add the page under any other page by passing the
parentPageNodeIdas an argument. If you pass an empty GUID the new page is created on root level. - Create the page.
You create new page using theCreatePagemethod of thePageManager. The method has two overloads. Set the last parameter of the method toNodeType.Group.
The method returns an object of typePageNode. Later, by setting the corresponding properties of the page node, you can set its name, description, title, creation date, visibility in the navigation, etc. - Save the changes. Save all changes that you have made to the page using the
SaveChangesmethod of thePageManager.
EXAMPLE: In the following code example, the
CreateGroupPageNativeAPImethod create a new group page:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Modules.Pages;
using Telerik.Sitefinity.Pages.Model;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Pages
{
public partial class PagesSnippets
{
public static void CreateGroupPageNativeAPI(string pageName, Guid parentPageNodeId)
{
PageManager manager = PageManager.GetManager();
if (parentPageNodeId == Guid.Empty)
{
parentPageNodeId = SiteInitializer.CurrentFrontendRootNodeId;
}
PageNode parent = manager.GetPageNode(parentPageNodeId);
var pageId = Guid.NewGuid();
PageNode pageNode = manager.CreatePage(parent, pageId, NodeType.Group);
pageNode.Name = pageName;
pageNode.Description = pageName;
pageNode.Title = pageName;
pageNode.UrlName = pageName;
pageNode.ShowInNavigation = true;
pageNode.DateCreated = DateTime.UtcNow;
pageNode.LastModified = DateTime.UtcNow;
manager.SaveChanges();
}
}
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.