-
-
Save toburger/5310035 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
namespace Intranet | |
{ | |
public static class CustomBreadcrumpCMS | |
{ | |
public static string GenerateMyBreadCrump(IDictionary<string, string> path) | |
{ | |
HttpContext currentContext = HttpContext.Current; | |
if (currentContext == null) | |
throw new InvalidOperationException("HttpContext.Current is Invalid"); | |
string rawUrl = HttpContext.Current.Request.RawUrl; | |
string myurl = "~" + rawUrl; | |
return string | |
.Join( | |
" > ", | |
path.Select(kb => | |
{ | |
if(kp.Key == myurl) | |
return "<b><a href='" + kp.Key + "'>" + kp.Value + "</a></b>"; | |
else | |
return "<a href='" + kp.Key + "'>" + kp.Value + "</a>"; | |
})); | |
} | |
public static Dictionary<string, string> GetMyCurrentTree(MenuCms currentitem) | |
{ | |
return GetParents(currentitem).Reverse().ToDictionary(i => i.Item1, i => i.Item2); | |
} | |
private static IEnumerable<Tuple<string, string>> GetParents(MenuCms currentitem) | |
{ | |
yield return Tuple.Create(currentitem.URL, currentitem.NameDE); | |
if (currentitem.Parent != null) | |
foreach (var parent in GetParents(currentitem.Parent)) | |
yield return parent; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment