From 24ee246a346868510bbb66f783bda0cfc52e32c6 Mon Sep 17 00:00:00 2001 From: Sergio Navarro Date: Fri, 26 Jun 2015 02:34:08 +0200 Subject: [PATCH 1/4] Differentiator is ignored processing placement In placement files shapeType uses "__" intead of '-' char for declaring a differenciator. The point is second one is used only in template files as can be seen in documentation http://docs.orchardproject.net/Documentation/Accessing-and-rendering-shapes#NamingShapesandTemplates However GetShapeType looks for '-' character ignoring placements for a ShapeType with a differentiator. This produces strange behaviors and a lot of headaches to users because when they set for example: in a placement file it forces all Fields_Common_Text shapes within the same Match to be rendered at Header:0 area instead of only affecting those with the SeoTitle differentiator. --- .../ShapePlacementStrategy/ShapePlacementParsingStrategy.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs b/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs index 2beb156d3..aff4d6872 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs @@ -111,8 +111,9 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy { differentiator = ""; shapeType = shapeLocation.ShapeType; var dashIndex = shapeType.LastIndexOf('-'); - if (dashIndex > 0 && dashIndex < shapeType.Length - 1) { - differentiator = shapeType.Substring(dashIndex + 1); + var dashIndex = shapeType.LastIndexOf("__"); + if (dashIndex > 0 && dashIndex < shapeType.Length - 2) { + differentiator = shapeType.Substring(dashIndex + 2); shapeType = shapeType.Substring(0, dashIndex); } } From 0f480193212330a0a32ab3af19620550b0e617d2 Mon Sep 17 00:00:00 2001 From: Sergio Navarro Date: Sun, 28 Jun 2015 01:11:06 +0200 Subject: [PATCH 2/4] Fixed bug addes on pull request --- .../ShapePlacementStrategy/ShapePlacementParsingStrategy.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs b/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs index aff4d6872..7f412f247 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs @@ -110,7 +110,6 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy { private void GetShapeType(PlacementShapeLocation shapeLocation, out string shapeType, out string differentiator) { differentiator = ""; shapeType = shapeLocation.ShapeType; - var dashIndex = shapeType.LastIndexOf('-'); var dashIndex = shapeType.LastIndexOf("__"); if (dashIndex > 0 && dashIndex < shapeType.Length - 2) { differentiator = shapeType.Substring(dashIndex + 2); From 43315c349fe3601a40d39af3c82f66adf9b671e6 Mon Sep 17 00:00:00 2001 From: Sergio Navarro Date: Tue, 14 Jul 2015 20:49:39 +0200 Subject: [PATCH 3/4] Update ShapePlacementParsingStrategy.cs --- .../ShapePlacementParsingStrategy.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs b/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs index 7f412f247..ff9894db0 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs @@ -107,13 +107,24 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy { } } - private void GetShapeType(PlacementShapeLocation shapeLocation, out string shapeType, out string differentiator) { + private void GetShapeType(PlacementShapeLocation shapeLocation, out string shapeType, out string differentiator) + { differentiator = ""; shapeType = shapeLocation.ShapeType; - var dashIndex = shapeType.LastIndexOf("__"); - if (dashIndex > 0 && dashIndex < shapeType.Length - 2) { - differentiator = shapeType.Substring(dashIndex + 2); - shapeType = shapeType.Substring(0, dashIndex); + var separatorLengh = 2; + var separatorIndex = shapeType.LastIndexOf("__"); + + var dashIndex = shapeType.LastIndexOf('-'); + if (dashIndex > separatorIndex) + { + separatorIndex = dashIndex; + separatorLengh = 1; + } + + if (separatorIndex > 0 && separatorIndex < shapeType.Length - separatorLengh) + { + differentiator = shapeType.Substring(separatorIndex + separatorLengh); + shapeType = shapeType.Substring(0, separatorIndex); } } From 3e1087ff5899997978393bc399f10fafa361640e Mon Sep 17 00:00:00 2001 From: Sergio Navarro Date: Tue, 14 Jul 2015 20:51:29 +0200 Subject: [PATCH 4/4] Update ShapePlacementParsingStrategy.cs --- .../ShapePlacementParsingStrategy.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs b/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs index ff9894db0..00cca9e4e 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs @@ -107,22 +107,19 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy { } } - private void GetShapeType(PlacementShapeLocation shapeLocation, out string shapeType, out string differentiator) - { + private void GetShapeType(PlacementShapeLocation shapeLocation, out string shapeType, out string differentiator) { differentiator = ""; shapeType = shapeLocation.ShapeType; var separatorLengh = 2; var separatorIndex = shapeType.LastIndexOf("__"); var dashIndex = shapeType.LastIndexOf('-'); - if (dashIndex > separatorIndex) - { + if (dashIndex > separatorIndex) { separatorIndex = dashIndex; separatorLengh = 1; } - if (separatorIndex > 0 && separatorIndex < shapeType.Length - separatorLengh) - { + if (separatorIndex > 0 && separatorIndex < shapeType.Length - separatorLengh) { differentiator = shapeType.Substring(separatorIndex + separatorLengh); shapeType = shapeType.Substring(0, separatorIndex); }