diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/ContentDisplayBase.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/ContentDisplayBase.cs index f50485744..fd5622254 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/ContentDisplayBase.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/ContentDisplayBase.cs @@ -95,7 +95,7 @@ namespace Orchard.Layouts.Services { // Adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit. ((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType); - var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable); + var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable, GetPath()); BindPlacement(context, null, stereotype); return context; @@ -121,7 +121,7 @@ namespace Orchard.Layouts.Services { Stereotype = stereotype, DisplayType = displayType, Differentiator = differentiator, - Path = VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo + Path = GetPath() }; // define which location should be used if none placement is hit @@ -140,5 +140,12 @@ namespace Orchard.Layouts.Services { }; }; } + + /// + /// Gets the current app-relative path, i.e. ~/my-blog/foo. + /// + private string GetPath() { + return VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(_requestContext.HttpContext.Request.Path)); + } } } diff --git a/src/Orchard/ContentManagement/DefaultContentDisplay.cs b/src/Orchard/ContentManagement/DefaultContentDisplay.cs index 71d100e54..1a949f275 100644 --- a/src/Orchard/ContentManagement/DefaultContentDisplay.cs +++ b/src/Orchard/ContentManagement/DefaultContentDisplay.cs @@ -103,7 +103,7 @@ namespace Orchard.ContentManagement { // adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit ((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType); - var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable); + var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable, GetPath()); BindPlacement(context, null, stereotype); _handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger); @@ -123,8 +123,6 @@ namespace Orchard.ContentManagement { var theme = workContext.CurrentTheme; var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id); - var request = _requestContext.HttpContext.Request; - ShapeDescriptor descriptor; if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) { var placementContext = new ShapePlacementContext { @@ -133,7 +131,7 @@ namespace Orchard.ContentManagement { Stereotype = stereotype, DisplayType = displayType, Differentiator = differentiator, - Path = VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo + Path = GetPath() }; // define which location should be used if none placement is hit @@ -152,5 +150,13 @@ namespace Orchard.ContentManagement { }; }; } + + /// + /// Gets the current app-relative path, i.e. ~/my-blog/foo. + /// + private string GetPath() + { + return VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(_requestContext.HttpContext.Request.Path)); + } } } diff --git a/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs b/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs index 986877b9b..9bc1affa7 100644 --- a/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs +++ b/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs @@ -69,7 +69,7 @@ namespace Orchard.ContentManagement.Drivers { ContentType = part.ContentItem.ContentType, Differentiator = editor.GetDifferentiator(), DisplayType = null, - Path = String.Empty + Path = context.Path }; var location = descriptor.Placement(placementContext).Location; diff --git a/src/Orchard/ContentManagement/Handlers/UpdateEditorContext.cs b/src/Orchard/ContentManagement/Handlers/UpdateEditorContext.cs index 47eee487e..b49dd8e97 100644 --- a/src/Orchard/ContentManagement/Handlers/UpdateEditorContext.cs +++ b/src/Orchard/ContentManagement/Handlers/UpdateEditorContext.cs @@ -4,14 +4,16 @@ using Orchard.DisplayManagement.Descriptors; namespace Orchard.ContentManagement.Handlers { public class UpdateEditorContext : BuildEditorContext { - public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable) + public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable, string path) : base(model, content, groupInfoId, shapeFactory) { ShapeTable = shapeTable; Updater = updater; + Path = path; } public IUpdateModel Updater { get; private set; } public ShapeTable ShapeTable { get; private set; } + public string Path { get; private set; } } } \ No newline at end of file