mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 11:44:41 +08:00
#19070: Showing the correct template in Shape Tracing for url alternates
Url alternates where created using Metadata.Displaying instead of Shape.Displaying thus making alternates too late in the pipeline to be processed by Shape Tracing. Work Item: 19070 --HG-- branch : 1.x
This commit is contained in:
@@ -45,27 +45,24 @@ namespace Orchard.DesignerTools.Services {
|
|||||||
|
|
||||||
public override void Displaying(ShapeDisplayingContext context) {
|
public override void Displaying(ShapeDisplayingContext context) {
|
||||||
|
|
||||||
context.ShapeMetadata.OnDisplaying(displayedContext => {
|
|
||||||
|
|
||||||
if (_urlAlternates.Value == null || !_urlAlternates.Value.Any()) {
|
if (_urlAlternates.Value == null || !_urlAlternates.Value.Any()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent applying alternate again, c.f. http://orchard.codeplex.com/workitem/18298
|
// prevent applying alternate again, c.f. http://orchard.codeplex.com/workitem/18298
|
||||||
if(displayedContext.ShapeMetadata.Alternates.Any(x => x.Contains("__url__"))) {
|
if (context.ShapeMetadata.Alternates.Any(x => x.Contains("__url__"))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// appends Url alternates to current ones
|
// appends Url alternates to current ones
|
||||||
displayedContext.ShapeMetadata.Alternates = displayedContext.ShapeMetadata.Alternates.SelectMany(
|
context.ShapeMetadata.Alternates = context.ShapeMetadata.Alternates.SelectMany(
|
||||||
alternate => new [] { alternate }.Union(_urlAlternates.Value.Select(a => alternate + "__url__" + a))
|
alternate => new [] { alternate }.Union(_urlAlternates.Value.Select(a => alternate + "__url__" + a))
|
||||||
).ToList();
|
).ToList();
|
||||||
|
|
||||||
// appends [ShapeType]__url__[Url] alternates
|
// appends [ShapeType]__url__[Url] alternates
|
||||||
displayedContext.ShapeMetadata.Alternates = _urlAlternates.Value.Select(url => displayedContext.ShapeMetadata.Type + "__url__" + url)
|
context.ShapeMetadata.Alternates = _urlAlternates.Value.Select(url => context.ShapeMetadata.Type + "__url__" + url)
|
||||||
.Union(displayedContext.ShapeMetadata.Alternates)
|
.Union(context.ShapeMetadata.Alternates)
|
||||||
.ToList();
|
.ToList();
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user