public abstract class UIOMaticSubSectionTreeController : UIOMaticTreeController
private const string UIOMaticRoutePath = Constants.SectionAlias + "/" + Constants.TreeAlias + "/";
public abstract string SubSectionAlias { get; }
public abstract string SubSectionName { get; }
protected string BaseRoutePath => quot;{SubSectionAlias}/{Constants.TreeAlias}/";
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) => UpdateRoutePath(base.GetTreeNodes(GetNodeId(id, queryStrings), queryStrings));
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) => base.GetMenuForNode(GetNodeId(id, queryStrings), queryStrings);
protected override TreeNode CreateRootNode(FormDataCollection queryStrings) => UpdateRoutePath(base.CreateRootNode(queryStrings));
protected virtual string GetNodeId(string id, FormDataCollection queryStrings) =>
!string.IsNullOrWhiteSpace(queryStrings.Get("startNodeId"))
? queryStrings.Get("startNodeId")
: (string.IsNullOrEmpty(id) || id == global::Umbraco.Core.Constants.System.RootString ? SubSectionAlias : id);
protected virtual TreeNodeCollection UpdateRoutePath(TreeNodeCollection nodes)
if (nodes == null || nodes.Count == 0) return nodes;
foreach (var node in nodes) UpdateRoutePath(node);
protected virtual TreeNode UpdateRoutePath(TreeNode node)
if (node?.RoutePath != null && node.RoutePath.StartsWith(UIOMaticRoutePath)) node.RoutePath = BaseRoutePath + (node.RoutePath.Length > UIOMaticRoutePath.Length ? node.RoutePath.Substring(UIOMaticRoutePath.Length) : "");
else if (node?.RoutePath == Constants.SectionAlias) node.RoutePath = SubSectionAlias;
if (node?.Name == "UI-O-Matic") node.Name = SubSectionName;