mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding AddCurrentPage and AddHomePage option in the navigation widget
--HG-- branch : 1.x
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web.Routing;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Aspects;
|
using Orchard.ContentManagement.Aspects;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
@@ -124,7 +125,29 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
menuItems = topLevelItems;
|
menuItems = topLevelItems;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var result = new List<MenuItem>(menuItems);
|
||||||
|
|
||||||
|
// inject the home page
|
||||||
|
if(part.AddHomePage) {
|
||||||
|
result.Insert(0, new MenuItem {
|
||||||
|
Href = _navigationManager.GetUrl("~/", null),
|
||||||
|
Text = T("Home")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// inject the current page
|
||||||
|
if (!part.AddCurrentPage) {
|
||||||
|
result.RemoveAt(result.Count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// prevent the home page to be added as the home page and the current page
|
||||||
|
if(result.Count == 2 && String.Equals(result[0].Href, result[1].Href, StringComparison.OrdinalIgnoreCase)) {
|
||||||
|
result.RemoveAt(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
menuItems = result;
|
||||||
|
|
||||||
menuShape.MenuName(menuName);
|
menuShape.MenuName(menuName);
|
||||||
NavigationHelper.PopulateMenu(shapeHelper, menuShape, menuShape, menuItems);
|
NavigationHelper.PopulateMenu(shapeHelper, menuShape, menuShape, menuItems);
|
||||||
|
|
||||||
@@ -139,6 +162,8 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
StartLevel = part.StartLevel,
|
StartLevel = part.StartLevel,
|
||||||
StopLevel = part.Levels,
|
StopLevel = part.Levels,
|
||||||
Breadcrumb = part.Breadcrumb,
|
Breadcrumb = part.Breadcrumb,
|
||||||
|
AddCurrentPage = part.AddCurrentPage,
|
||||||
|
AddHomePage = part.AddHomePage,
|
||||||
Menus = _menuService.GetMenus(),
|
Menus = _menuService.GetMenus(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -153,6 +178,8 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
part.StartLevel = model.StartLevel;
|
part.StartLevel = model.StartLevel;
|
||||||
part.Levels = model.StopLevel;
|
part.Levels = model.StopLevel;
|
||||||
part.Breadcrumb = model.Breadcrumb;
|
part.Breadcrumb = model.Breadcrumb;
|
||||||
|
part.AddHomePage = model.AddHomePage;
|
||||||
|
part.AddCurrentPage = model.AddCurrentPage;
|
||||||
part.Menu = _contentManager.Get(model.CurrentMenuId).Record;
|
part.Menu = _contentManager.Get(model.CurrentMenuId).Record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ namespace Orchard.Core.Navigation {
|
|||||||
.Column<int>("StartLevel")
|
.Column<int>("StartLevel")
|
||||||
.Column<int>("Levels")
|
.Column<int>("Levels")
|
||||||
.Column<bool>("Breadcrumb")
|
.Column<bool>("Breadcrumb")
|
||||||
|
.Column<bool>("AddHomePage")
|
||||||
|
.Column<bool>("AddCurrentPage")
|
||||||
.Column<int>("Menu_id")
|
.Column<int>("Menu_id")
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -123,6 +125,8 @@ namespace Orchard.Core.Navigation {
|
|||||||
.Column<int>("StartLevel")
|
.Column<int>("StartLevel")
|
||||||
.Column<int>("Levels")
|
.Column<int>("Levels")
|
||||||
.Column<bool>("Breadcrumb")
|
.Column<bool>("Breadcrumb")
|
||||||
|
.Column<bool>("AddHomePage")
|
||||||
|
.Column<bool>("AddCurrentPage")
|
||||||
.Column<int>("Menu_id")
|
.Column<int>("Menu_id")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,16 @@ namespace Orchard.Core.Navigation.Models {
|
|||||||
set { Record.Breadcrumb = value; }
|
set { Record.Breadcrumb = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AddHomePage {
|
||||||
|
get { return Record.AddHomePage; }
|
||||||
|
set { Record.AddHomePage = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AddCurrentPage {
|
||||||
|
get { return Record.AddCurrentPage; }
|
||||||
|
set { Record.AddCurrentPage = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public ContentItemRecord Menu {
|
public ContentItemRecord Menu {
|
||||||
get { return Record.Menu; }
|
get { return Record.Menu; }
|
||||||
set { Record.Menu = value; }
|
set { Record.Menu = value; }
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ namespace Orchard.Core.Navigation.Models {
|
|||||||
public virtual int StartLevel { get; set; }
|
public virtual int StartLevel { get; set; }
|
||||||
public virtual int Levels { get; set; }
|
public virtual int Levels { get; set; }
|
||||||
public virtual bool Breadcrumb { get; set; }
|
public virtual bool Breadcrumb { get; set; }
|
||||||
|
public virtual bool AddHomePage { get; set; }
|
||||||
|
public virtual bool AddCurrentPage { get; set; }
|
||||||
|
|
||||||
public virtual ContentItemRecord Menu { get; set; }
|
public virtual ContentItemRecord Menu { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,7 @@ namespace Orchard.Core.Navigation.ViewModels {
|
|||||||
public int StartLevel { get; set; }
|
public int StartLevel { get; set; }
|
||||||
public int StopLevel { get; set; }
|
public int StopLevel { get; set; }
|
||||||
public bool Breadcrumb { get; set; }
|
public bool Breadcrumb { get; set; }
|
||||||
|
public bool AddHomePage { get; set; }
|
||||||
|
public bool AddCurrentPage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,3 +29,17 @@
|
|||||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Breadcrumb)">@T("Display as Breadcrumb")</label>
|
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Breadcrumb)">@T("Display as Breadcrumb")</label>
|
||||||
<span class="hint">@T("Check to render the path to the current content item.")</span>
|
<span class="hint">@T("Check to render the path to the current content item.")</span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<div data-controllerid="@Html.FieldIdFor(m => m.Breadcrumb)">
|
||||||
|
<fieldset>
|
||||||
|
@Html.EditorFor(m => m.AddHomePage)
|
||||||
|
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AddHomePage)">@T("Add the home page as the first element")</label>
|
||||||
|
<span class="hint">@T("Check to render the home page as the first element of the breadcrumb.")</span>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
@Html.EditorFor(m => m.AddCurrentPage)
|
||||||
|
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AddCurrentPage)">@T("Add the current content item as the last element")</label>
|
||||||
|
<span class="hint">@T("Check to render the current content item as the last element.")</span>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user