mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 01:57:55 +08:00
Fixing exception when there are no items in the main menu
--HG-- branch : 1.x
This commit is contained in:
@@ -10,15 +10,19 @@ namespace Orchard.Utility {
|
||||
public static string GetNext(IEnumerable<MenuItem> menuItems) {
|
||||
|
||||
var maxMenuItem = menuItems.Where(mi => PositionHasMajorNumber(mi)).OrderByDescending(mi => mi.Position, new FlatPositionComparer()).FirstOrDefault();
|
||||
var positionParts = maxMenuItem.Position.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Where(s => s.Trim().Length > 0);
|
||||
if (positionParts.Count() > 0) {
|
||||
int result;
|
||||
if (int.TryParse(positionParts.ElementAt(0), out result)) {
|
||||
return (result + 1).ToString();
|
||||
|
||||
// are there any menu item ?
|
||||
if (maxMenuItem != null) {
|
||||
|
||||
var positionParts = maxMenuItem.Position.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries).Where(s => s.Trim().Length > 0).ToList();
|
||||
if (positionParts.Any()) {
|
||||
int result;
|
||||
if (int.TryParse(positionParts.ElementAt(0), out result)) {
|
||||
return (result + 1).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return "1";
|
||||
}
|
||||
|
||||
@@ -30,7 +34,7 @@ namespace Orchard.Utility {
|
||||
// first one in this major position number
|
||||
return majorStr;
|
||||
}
|
||||
var positionParts = maxMenuItem.Position.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Where(s => s.Trim().Length > 0);
|
||||
var positionParts = maxMenuItem.Position.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Where(s => s.Trim().Length > 0).ToList();
|
||||
if (positionParts.Count() > 1) {
|
||||
int result;
|
||||
if (int.TryParse(positionParts.ElementAt(1), out result)) {
|
||||
|
Reference in New Issue
Block a user