mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 02:44:52 +08:00
Adding <Match Path="" /> predicate in placement files
Can use * at the end of the string Path="/" matches the homepage --HG-- branch : dev extra : transplant_source : %FA%B8%DB%0D%DDI%9DbP%BC%D8%F6%B31j%24%BB%E6%AD%FE
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using ClaySharp.Implementation;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
@@ -100,6 +101,7 @@ namespace Orchard.ContentManagement {
|
||||
//var theme = workContext.CurrentTheme;
|
||||
var theme = _themeService.Value.GetRequestTheme(_requestContext);
|
||||
var shapeTable = _shapeTableManager.GetShapeTable(theme.Id);
|
||||
var request = _requestContext.HttpContext.Request;
|
||||
|
||||
ShapeDescriptor descriptor;
|
||||
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
|
||||
@@ -107,6 +109,7 @@ namespace Orchard.ContentManagement {
|
||||
ContentType = context.ContentItem.ContentType,
|
||||
DisplayType = displayType,
|
||||
Differentiator = differentiator,
|
||||
Path = request.Path.Substring((request.ApplicationPath ?? "").Length)
|
||||
};
|
||||
var location = descriptor.Placement(placementContext);
|
||||
return location ?? defaultLocation;
|
||||
|
@@ -111,5 +111,6 @@ namespace Orchard.DisplayManagement.Descriptors {
|
||||
public string ContentType { get; set; }
|
||||
public string DisplayType { get; set; }
|
||||
public string Differentiator { get; set; }
|
||||
public string Path { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -98,6 +98,12 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy {
|
||||
return ctx => (ctx.DisplayType ?? "").StartsWith(prefix) && predicate(ctx);
|
||||
}
|
||||
return ctx => (ctx.DisplayType == expression) && predicate(ctx);
|
||||
case "Path":
|
||||
if (expression.EndsWith("*")) {
|
||||
var prefix = expression.Substring(0, expression.Length - 1);
|
||||
return ctx => (ctx.Path ?? "").StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && predicate(ctx);
|
||||
}
|
||||
return ctx => (ctx.Path.Equals(expression, StringComparison.OrdinalIgnoreCase)) && predicate(ctx);
|
||||
}
|
||||
return predicate;
|
||||
}
|
||||
|
Reference in New Issue
Block a user