Skip to content

Instantly share code, notes, and snippets.

@daniiiol
Created April 29, 2016 08:35
Show Gist options
  • Save daniiiol/b9e1a0a715221c7eea0384694ad63c67 to your computer and use it in GitHub Desktop.
Save daniiiol/b9e1a0a715221c7eea0384694ad63c67 to your computer and use it in GitHub Desktop.
using System;
using Sitecore.Data.Items;
using Sitecore.Shell.Applications.ContentEditor;
namespace Custom.Common.Fields
{
/// <summary>
/// The custom tree list.
/// </summary>
public class PathTreeList : TreeList
{
/// <summary>
/// Gets the header value with the path.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>
/// Header text for list item.
/// </returns>
protected override string GetHeaderValue(Item item)
{
if (item == null)
{
return base.GetHeaderValue(null);
}
var result = item.DisplayName;
var nextItem = item.Parent;
while (nextItem != null && !nextItem.TemplateName.Equals("HomeTemplateName", StringComparison.InvariantCultureIgnoreCase))
{
result = $"{nextItem.DisplayName}/{result}";
nextItem = nextItem.Parent;
}
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment