Reorder forum groups
To reorder forum groups, you must perform the following:
- Change the ordinal of the specified group.
Query the specified group and modify the value of itsOrdinalproperty. For more information, see For developers: Modify forum groups. - Update the ordinals of the other groups.
Update the values of theOrdinalproperties of the other groups according to the new ordinal of the specified group.
Here is a code example:
C#
using System;
using System.Linq;
using Telerik.Sitefinity.Forums;
namespace SitefinityWebApp
{
public class ReorderForumGroups_MoveForumGroup
{
public static void MoveForumGroup(Guid groupId, int newOrdinal)
{
ForumsManager forumsManager = ForumsManager.GetManager();
var forumGroup = forumsManager.GetGroup(groupId);
//Validate new position
if (newOrdinal < 0 || newOrdinal == forumGroup.Ordinal)
{
return;
}
else if (newOrdinal > forumsManager.GetGroups().Count())
{
newOrdinal = forumsManager.GetGroups().Count();
}
//Preserve the old ordinal value
var oldOrdinal = forumGroup.Ordinal;
//Assign the new ordinal value
forumGroup.Ordinal = newOrdinal;
//Reorder the other groups.
foreach (var group in forumsManager.GetGroups())
{
if (group.Equals(forumGroup))
{
continue;
}
//Moving up
if (newOrdinal < oldOrdinal)
{
//Update only the items between the new and the old position
if (group.Ordinal >= newOrdinal && group.Ordinal < oldOrdinal)
{
group.Ordinal++;
}
}
//Moving down
else
{
//Update only the items between the new and the old position
if (group.Ordinal <= newOrdinal && group.Ordinal > oldOrdinal)
{
group.Ordinal--;
}
}
}
forumsManager.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.