Remove fallback for field specialization

Fallback logic is implied by ordering in placement.info

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-12-10 13:02:54 -08:00
parent e9380fb02f
commit 04f733c34b
2 changed files with 9 additions and 22 deletions
@@ -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;
}; };
@@ -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);
} }