mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Remove fallback for field specialization
Fallback logic is implied by ordering in placement.info --HG-- branch : dev
This commit is contained in:
@@ -103,30 +103,13 @@ namespace Orchard.ContentManagement {
|
|||||||
|
|
||||||
ShapeDescriptor descriptor;
|
ShapeDescriptor descriptor;
|
||||||
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
|
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
|
||||||
ShapePlacementContext placementContext;
|
var placementContext = new ShapePlacementContext {
|
||||||
string location;
|
|
||||||
|
|
||||||
// First, look up placement with differentiator
|
|
||||||
if (!string.IsNullOrEmpty(differentiator)) {
|
|
||||||
placementContext = new ShapePlacementContext {
|
|
||||||
ContentType = context.ContentItem.ContentType,
|
ContentType = context.ContentItem.ContentType,
|
||||||
DisplayType = displayType,
|
DisplayType = displayType,
|
||||||
Differentiator = differentiator,
|
Differentiator = differentiator,
|
||||||
};
|
};
|
||||||
location = descriptor.Placement(placementContext);
|
var location = descriptor.Placement(placementContext);
|
||||||
if (!string.IsNullOrEmpty(location))
|
return location ?? defaultLocation;
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then fallback to placement without differentiator
|
|
||||||
placementContext = new ShapePlacementContext {
|
|
||||||
ContentType = context.ContentItem.ContentType,
|
|
||||||
DisplayType = displayType,
|
|
||||||
Differentiator = null,
|
|
||||||
};
|
|
||||||
location = descriptor.Placement(placementContext);
|
|
||||||
if (!string.IsNullOrEmpty(location))
|
|
||||||
return location;
|
|
||||||
}
|
}
|
||||||
return defaultLocation;
|
return defaultLocation;
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-1
@@ -58,7 +58,11 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy {
|
|||||||
string differentiator;
|
string differentiator;
|
||||||
GetShapeType(shapeLocation, out shapeType, out differentiator);
|
GetShapeType(shapeLocation, out shapeType, out differentiator);
|
||||||
|
|
||||||
Func<ShapePlacementContext, bool> predicate = ctx => (ctx.Differentiator ?? "") == differentiator;
|
Func<ShapePlacementContext, bool> predicate = ctx => true;
|
||||||
|
if (differentiator != "") {
|
||||||
|
predicate = ctx => (ctx.Differentiator ?? "") == differentiator;
|
||||||
|
}
|
||||||
|
|
||||||
if (matches.Any()) {
|
if (matches.Any()) {
|
||||||
predicate = matches.SelectMany(match => match.Terms).Aggregate(predicate, BuildPredicate);
|
predicate = matches.SelectMany(match => match.Terms).Aggregate(predicate, BuildPredicate);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user