Created
January 21, 2018 10:25
-
-
Save hermanussen/2a87013d89597e97cd4709ad9c9a2d6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" %> | |
<%@ Import Namespace="System.Linq" %> | |
<% | |
if ("POST".Equals(Request.HttpMethod)) | |
{ | |
Sitecore.Data.Items.Item item = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(Request["id"])); | |
if (item.Parent != null) | |
{ | |
Response.Write(string.Format("<ul><li><a href=\"{0}\">{1}</a></li></ul>", item.ParentID, item.DisplayName)); | |
} | |
else | |
{ | |
Response.Write(string.Format("<ul><li>{0}</li></ul>", item.DisplayName)); | |
} | |
Response.End(); | |
} | |
else | |
{ | |
DataBind(); | |
} | |
%> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title>InverseContentTreeViewer</title> | |
<script type="text/javascript" src="http://www.google.com/jsapi"></script> | |
<script type="text/javascript"> | |
function expandItem(ev) { | |
ev.preventDefault(); | |
var $self = $(this); | |
$.post('InverseContentTreeViewer.aspx', { id: $self.attr("href") }, function (data) { | |
var $added = $self.parent().append(data); | |
$added.find("ul li a").click(expandItem); | |
$added.find("ul li").addClass("Collapsed"); | |
}); | |
$self.parent().removeClass("Collapsed"); | |
$self.parent().addClass("Expanded"); | |
} | |
google.load("jquery", "1.5.0"); | |
google.setOnLoadCallback(function () { | |
$("#browser a").click(expandItem); | |
$("#browser li").addClass("Collapsed"); | |
}); | |
</script> | |
<style type=text/css> | |
.TreeView | |
{ | |
font: Verdana; | |
line-height: 20px; | |
cursor: pointer; | |
font-style: normal; | |
} | |
.TreeView li | |
{ | |
/* The padding is for the tree view nodes */ | |
padding: 0 0 0 18px; | |
float: left; | |
width: 100%; | |
list-style: none; | |
} | |
.TreeView, .TreeView ul | |
{ | |
margin: 0; | |
padding: 0; | |
} | |
LI.Expanded | |
{ | |
background: url(/sitecore/shell/Themes/Standard/Images/collapse15x15.gif) no-repeat left top; | |
} | |
LI.Expanded ul | |
{ | |
display: block; | |
} | |
LI.Collapsed | |
{ | |
background: url(/sitecore/shell/Themes/Standard/Images/expand15x15.gif) no-repeat left top; | |
} | |
LI.Collapsed ul | |
{ | |
display: none; | |
} | |
</style> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<div> | |
<asp:Repeater runat="server" DataSource=<%# Sitecore.Context.Database.GetRootItem().Axes.SelectItems("descendant::*[*=null]").GroupBy(it => it.Parent.ID) %>> | |
<HeaderTemplate><ul id="browser" class="TreeView"></HeaderTemplate> | |
<ItemTemplate> | |
<li> | |
<asp:Repeater runat="server" DataSource="<%# (IGrouping<Sitecore.Data.ID,Sitecore.Data.Items.Item>) Container.DataItem %>"> | |
<HeaderTemplate><a href="<%# ((IGrouping<Sitecore.Data.ID,Sitecore.Data.Items.Item>) DataBinder.Eval(Container, "Parent.Parent.DataItem")).Key %>"></HeaderTemplate> | |
<ItemTemplate> | |
<%# ((Sitecore.Data.Items.Item) Container.DataItem).DisplayName %> | |
</ItemTemplate> | |
<SeparatorTemplate><br /></SeparatorTemplate> | |
<FooterTemplate> | |
</a></FooterTemplate> | |
</asp:Repeater> | |
</li> | |
</ItemTemplate> | |
<FooterTemplate></ul></FooterTemplate> | |
</asp:Repeater> | |
</div> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment