Skip to content

Instantly share code, notes, and snippets.

@uniquelau
Created September 2, 2011 11:24
Show Gist options
  • Save uniquelau/1188408 to your computer and use it in GitHub Desktop.
Save uniquelau/1188408 to your computer and use it in GitHub Desktop.
Hide Nodes in Umbraco Tree
using System;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
using umbraco.cms.presentation.Trees;
using umbraco.interfaces;
namespace Abbott.Corporate.Logic.Events
{
public class HideGridNodeOnLoad : ApplicationBase
{
public HideGridNodeOnLoad()
{
// Event Handler - Tree Nodes
BaseContentTree.BeforeNodeRender += new BaseTree.BeforeNodeRenderEventHandler(BeforeNodeRenderHandler);
}
private void BeforeNodeRenderHandler(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
{
// make sure we are dealing with a content node and not another type of node (like "media").
if (node.NodeType.ToLower() == "content")
{
// let's make sure we are dealing with all users, apart from 'Administrators' before we do anything...
if (umbraco.helper.GetCurrentUmbracoUser().UserType.Alias != "Administrator")
{
// Lets Go!
// **********************************************************************
// Hide the Nodes which contain the Grid Layout data.
int docid = int.Parse(node.NodeID); // get the Node Id
Document doc = new Document(docid); // get the document
if (doc.ContentType.Alias == "layoutGridFolders")
{
node = null;
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment