mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Getting routable to work for the ItemDisplayLink HtmlHelper ext.
--HG-- branch : dev
This commit is contained in:
@@ -77,6 +77,7 @@
|
|||||||
<Compile Include="Contents\Controllers\ItemController.cs" />
|
<Compile Include="Contents\Controllers\ItemController.cs" />
|
||||||
<Compile Include="Contents\Drivers\ContentsDriver.cs" />
|
<Compile Include="Contents\Drivers\ContentsDriver.cs" />
|
||||||
<Compile Include="Contents\Handlers\ContentsHandler.cs" />
|
<Compile Include="Contents\Handlers\ContentsHandler.cs" />
|
||||||
|
<Compile Include="Routable\Services\RoutableHomePageProvider.cs" />
|
||||||
<Compile Include="Contents\ViewModels\EditItemViewModel.cs" />
|
<Compile Include="Contents\ViewModels\EditItemViewModel.cs" />
|
||||||
<Compile Include="Contents\ViewModels\ListContentsViewModel.cs" />
|
<Compile Include="Contents\ViewModels\ListContentsViewModel.cs" />
|
||||||
<Compile Include="Contents\ViewModels\ListContentTypesViewModel.cs" />
|
<Compile Include="Contents\ViewModels\ListContentTypesViewModel.cs" />
|
||||||
@@ -276,7 +277,7 @@
|
|||||||
<Content Include="Routable\Module.txt" />
|
<Content Include="Routable\Module.txt" />
|
||||||
<Content Include="Routable\Scripts\jquery.slugify.js" />
|
<Content Include="Routable\Scripts\jquery.slugify.js" />
|
||||||
<Content Include="Routable\Views\EditorTemplates\Parts\Routable.IsRoutable.ascx" />
|
<Content Include="Routable\Views\EditorTemplates\Parts\Routable.IsRoutable.ascx" />
|
||||||
<Content Include="Routable\Views\Item\Display.aspx" />
|
<Content Include="Routable\Views\Item\Display.ascx" />
|
||||||
<Content Include="Settings\Module.txt" />
|
<Content Include="Settings\Module.txt" />
|
||||||
<Content Include="Settings\Styles\admin.css" />
|
<Content Include="Settings\Styles\admin.css" />
|
||||||
<Content Include="Settings\Views\Admin\Index.ascx" />
|
<Content Include="Settings\Views\Admin\Index.ascx" />
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ namespace Orchard.Core.Routable.Drivers {
|
|||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private const string TemplateName = "Parts/Routable.IsRoutable";
|
private const string TemplateName = "Parts/Routable.IsRoutable";
|
||||||
|
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|||||||
@@ -1,11 +1,31 @@
|
|||||||
using Orchard.ContentManagement.Handlers;
|
using System.Web.Routing;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Core.Routable.Models;
|
using Orchard.Core.Routable.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
|
|
||||||
namespace Orchard.Core.Routable.Handlers {
|
namespace Orchard.Core.Routable.Handlers {
|
||||||
public class RoutableHandler : ContentHandler {
|
public class RoutableHandler : ContentHandler {
|
||||||
public RoutableHandler(IRepository<RoutableRecord> repository) {
|
private readonly IRoutablePathConstraint _routablePathConstraint;
|
||||||
|
|
||||||
|
public RoutableHandler(IRepository<RoutableRecord> repository, IRoutablePathConstraint routablePathConstraint) {
|
||||||
|
_routablePathConstraint = routablePathConstraint;
|
||||||
Filters.Add(StorageFilter.For(repository));
|
Filters.Add(StorageFilter.For(repository));
|
||||||
|
|
||||||
|
OnPublished<IsRoutable>((context, routable) => _routablePathConstraint.AddPath(routable.Record.Path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class IsRoutableHandler : ContentHandlerBase {
|
||||||
|
public override void GetContentItemMetadata(GetContentItemMetadataContext context) {
|
||||||
|
var routable = context.ContentItem.As<IsRoutable>();
|
||||||
|
if (routable != null) {
|
||||||
|
context.Metadata.DisplayRouteValues = new RouteValueDictionary {
|
||||||
|
{"Area", "Routable"},
|
||||||
|
{"Controller", "Item"},
|
||||||
|
{"Action", "Display"},
|
||||||
|
{"path", routable.Record.Path}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
src/Orchard.Web/Core/Routable/Views/Item/Display.ascx
Normal file
3
src/Orchard.Web/Core/Routable/Views/Item/Display.ascx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Routable.ViewModels.RoutableDisplayViewModel>" %>
|
||||||
|
<% Html.AddTitleParts(Model.Routable.Item.Title); %>
|
||||||
|
<%: Html.DisplayForItem(m=>m.Routable) %>
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<Orchard.Core.Routable.ViewModels.RoutableDisplayViewModel>" %>
|
|
||||||
<% Html.AddTitleParts(Model.Routable.Item.Title); %>
|
|
||||||
<%: Html.DisplayForItem(m=>m.Routable) %>
|
|
||||||
Reference in New Issue
Block a user