Skip to content

Instantly share code, notes, and snippets.

@warrenbuckley
Created December 7, 2013 19:44
Show Gist options
  • Select an option

  • Save warrenbuckley/7847581 to your computer and use it in GitHub Desktop.

Select an option

Save warrenbuckley/7847581 to your computer and use it in GitHub Desktop.
using System;
using System.Net.Http.Formatting;
using Umbraco.Core;
using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc;
using Umbraco.Web.Trees;
namespace UmbracoDiagnostics
{
[Tree("developer", "diagnosticsTree", "Diagnostics")]
[PluginController("Diagnostics")]
public class DiagnosticsTreeController : TreeController
{
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
//check if we're rendering the root node's children
if (id == Constants.System.Root.ToInvariantString())
{
//Nodes that we will return
var nodes = new TreeNodeCollection();
//Temp items for testing
var items = new[] { "General", "Packages", "Users" , "Domains", "Assemblies", "Permissions", "Events", "MVC Routes", "Trees" };
foreach (var item in items)
{
//When clicked - /App_Plugins/Diagnostics/backoffice/diagnosticsTree/edit.html
//URL in address bar - /developer/diagnosticsTree/edit/General
var route = string.Format("developer/diagnosticsTree/{0}", item);
var nodeToAdd = CreateTreeNode(item, null, queryStrings, item, "icon-server", false, route);
//Add it to the collection
nodes.Add(nodeToAdd);
}
//Return the nodes
return nodes;
}
//this tree doesn't suport rendering more than 1 level
throw new NotSupportedException();
}
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
{
throw new System.NotImplementedException();
}
}
}
@mvanhelmont
Copy link
Copy Markdown

var nodeToAdd = CreateTreeNode(item, null, queryStrings, item, "icon-server", false);

nodeToAdd.RoutePath = "/developer/diagnosticsTree/general/" + item.Id;

Hope it helps it's required to pass a id to the routepath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment