mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
- Adding the new menuitem content type, which has a url for the link. Also welding menupart to menuitems.
--HG-- branch : dev
This commit is contained in:
15
src/Orchard.Web/Core/Navigation/Models/MenuItem.cs
Normal file
15
src/Orchard.Web/Core/Navigation/Models/MenuItem.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Navigation.Records;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
public class MenuItem : ContentPart<MenuItemRecord> {
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public int Id { get { return ContentItem.Id; } }
|
||||
|
||||
public string Url {
|
||||
get { return Record.Url; }
|
||||
set { Record.Url = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/Orchard.Web/Core/Navigation/Models/MenuItemDriver.cs
Normal file
29
src/Orchard.Web/Core/Navigation/Models/MenuItemDriver.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
[UsedImplicitly]
|
||||
public class MenuItemDriver : ContentItemDriver<MenuItem> {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public readonly static ContentType ContentType = new ContentType {
|
||||
Name = "menuitem",
|
||||
DisplayName = "Menu Item"
|
||||
};
|
||||
|
||||
public MenuItemDriver(IOrchardServices orchardServices) {
|
||||
_orchardServices = orchardServices;
|
||||
}
|
||||
|
||||
protected override ContentType GetContentType() {
|
||||
return ContentType;
|
||||
}
|
||||
|
||||
protected override string Prefix { get { return ""; } }
|
||||
|
||||
protected override string GetDisplayText(MenuItem item) {
|
||||
return item.Url;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/Orchard.Web/Core/Navigation/Models/MenuItemHandler.cs
Normal file
15
src/Orchard.Web/Core/Navigation/Models/MenuItemHandler.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Orchard.Core.Navigation.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
public class MenuItemHandler : ContentHandler {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public MenuItemHandler(IRepository<MenuItemRecord> repository, IOrchardServices orchardServices) {
|
||||
_orchardServices = orchardServices;
|
||||
Filters.Add(new ActivatingFilter<MenuItem>(MenuItemDriver.ContentType.Name));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace Orchard.Core.Navigation.Models {
|
||||
public MenuPartHandler(IRepository<MenuPartRecord> menuPartRepository) {
|
||||
Filters.Add(new ActivatingFilter<MenuPart>("blog"));
|
||||
Filters.Add(new ActivatingFilter<MenuPart>("page"));
|
||||
Filters.Add(new ActivatingFilter<MenuPart>("menuitem"));
|
||||
Filters.Add(StorageFilter.For(menuPartRepository));
|
||||
|
||||
OnActivated<MenuPart>((ctx, x) => {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Navigation.Records {
|
||||
public class MenuItemRecord : ContentPartRecord {
|
||||
public virtual string Url { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ namespace Orchard.Core.Navigation.Services {
|
||||
foreach (var menuPart in menuParts) {
|
||||
if (menuPart != null ) {
|
||||
MenuPart part = menuPart;
|
||||
// Add item url.
|
||||
builder.Add(menu => menu
|
||||
.Add(part.MenuText, part.MenuPosition));
|
||||
}
|
||||
|
||||
@@ -104,10 +104,14 @@
|
||||
<Compile Include="Feeds\Rss\RssResult.cs" />
|
||||
<Compile Include="Navigation\AdminMenu.cs" />
|
||||
<Compile Include="Navigation\Controllers\AdminController.cs" />
|
||||
<Compile Include="Navigation\Models\MenuItem.cs" />
|
||||
<Compile Include="Navigation\Models\MenuItemDriver.cs" />
|
||||
<Compile Include="Navigation\Models\MenuItemHandler.cs" />
|
||||
<Compile Include="Navigation\Models\MenuPart.cs" />
|
||||
<Compile Include="Navigation\Models\MenuPartDriver.cs" />
|
||||
<Compile Include="Navigation\Models\MenuPartHandler.cs" />
|
||||
<Compile Include="Navigation\Permissions.cs" />
|
||||
<Compile Include="Navigation\Records\MenuItemRecord.cs" />
|
||||
<Compile Include="Navigation\Records\MenuPartRecord.cs" />
|
||||
<Compile Include="Navigation\Services\MainMenu.cs" />
|
||||
<Compile Include="Navigation\Services\MainMenuFilter.cs" />
|
||||
|
||||
Reference in New Issue
Block a user