Fixing navigation hierarchy building

--HG--
branch : 1.5.x
This commit is contained in:
Sebastien Ros
2012-07-19 13:41:42 -07:00
parent 76bb42cff2
commit 1926af7ca4
+11 -14
View File
@@ -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('.');
if (lastSegment != -1) {
parentPosition = item.Position.Substring(0, lastSegment);
}
while (parent == null && !String.IsNullOrEmpty(position)) { if (index.TryGetValue(parentPosition, out parent)) {
if (index.TryGetValue(position, out parent)) { parent.Items = parent.Items.Concat(new [] { item });
parent.Items = parent.Items.Concat(new [] { item }); }
} else {
result.Add(item);
position = position.Substring(0, position.Length - 1); }
};
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;