mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 12:09:41 +08:00
- Adding the RoutableAspect editor template's permalink slug prefix display based on container slugs
- Got the rest of the hard coded prefix usage out of the RoutableAspect's editor template --HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045731
This commit is contained in:
26
src/Orchard.Web/Core/Common/Models/RoutableAspectHandler.cs
Normal file
26
src/Orchard.Web/Core/Common/Models/RoutableAspectHandler.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Text;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Core.Common.Models {
|
||||
[UsedImplicitly]
|
||||
public class RoutableAspectHandler : ContentHandler
|
||||
{
|
||||
public RoutableAspectHandler() {
|
||||
OnGetEditorViewModel<RoutableAspect>((context, routable) => {
|
||||
var containerPathBuilder = new StringBuilder();
|
||||
var container = context.ContentItem.As<ICommonAspect>().Container;
|
||||
|
||||
while (container != null) {
|
||||
if (container.Is<RoutableAspect>())
|
||||
containerPathBuilder.Insert(0, string.Format("{0}/", container.As<RoutableAspect>().Slug));
|
||||
container = container.ContentItem.As<ICommonAspect>().Container;
|
||||
}
|
||||
|
||||
routable.ContainerPath = containerPathBuilder.ToString();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user