mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fixing navigation hierarchy building
--HG-- branch : 1.5.x
This commit is contained in:
@@ -196,27 +196,24 @@ namespace Orchard.UI.Navigation {
|
|||||||
|
|
||||||
foreach (var item in items) {
|
foreach (var item in items) {
|
||||||
MenuItem parent = null;
|
MenuItem parent = null;
|
||||||
var position = item.Position;
|
var parentPosition = String.Empty;
|
||||||
|
|
||||||
|
var lastSegment = item.Position.LastIndexOf('.');
|
||||||
while (parent == null && !String.IsNullOrEmpty(position)) {
|
if (lastSegment != -1) {
|
||||||
if (index.TryGetValue(position, out parent)) {
|
parentPosition = item.Position.Substring(0, lastSegment);
|
||||||
parent.Items = parent.Items.Concat(new [] { item });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
position = position.Substring(0, position.Length - 1);
|
if (index.TryGetValue(parentPosition, out parent)) {
|
||||||
};
|
parent.Items = parent.Items.Concat(new [] { item });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
if (!index.ContainsKey(item.Position)) {
|
if (!index.ContainsKey(item.Position)) {
|
||||||
// prevent invalid positions
|
// prevent invalid positions
|
||||||
index.Add(item.Position, item);
|
index.Add(item.Position, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if the current element has no parent, it's a top level item
|
|
||||||
if (parent == null) {
|
|
||||||
result.Add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user