diff --git a/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs b/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs index d3b6b8b8c..706eaec36 100644 --- a/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs +++ b/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs @@ -8,17 +8,24 @@ using Orchard.Core.Routable.Models; using Orchard.Core.Routable.Services; using Orchard.Core.Routable.ViewModels; using Orchard.Localization; +using Orchard.Mvc; using Orchard.Services; +using Orchard.Utility.Extensions; namespace Orchard.Core.Routable.Drivers { public class RoutePartDriver : ContentPartDriver { private readonly IOrchardServices _services; private readonly IRoutableService _routableService; + private readonly IHttpContextAccessor _httpContextAccessor; private readonly IHomePageProvider _routableHomePageProvider; - public RoutePartDriver(IOrchardServices services, IRoutableService routableService, IEnumerable homePageProviders) { + public RoutePartDriver(IOrchardServices services, + IRoutableService routableService, + IEnumerable homePageProviders, + IHttpContextAccessor httpContextAccessor) { _services = services; _routableService = routableService; + _httpContextAccessor = httpContextAccessor; _routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name); T = NullLocalizer.Instance; } @@ -59,10 +66,9 @@ namespace Orchard.Core.Routable.Drivers { ContainerId = GetContainerId(part), }; - var containerPath = part.GetContainerPath(); - model.DisplayLeadingPath = !string.IsNullOrWhiteSpace(containerPath) - ? string.Format("{0}/", containerPath) - : ""; + var request = _httpContextAccessor.Current().Request; + var containerUrl = new UriBuilder(request.ToRootUrlString()) { Path = (request.ApplicationPath ?? "").TrimEnd('/') + "/" + (part.GetContainerPath() ?? "") }; + model.ContainerAbsoluteUrl = containerUrl.Uri.ToString().TrimEnd('/'); model.PromoteToHomePage = model.Id != 0 && part.Path != null && _routableHomePageProvider != null && _services.WorkContext.CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id); return ContentShape("Parts_Routable_Edit", diff --git a/src/Orchard.Web/Core/Routable/ViewModels/RoutableEditorViewModel.cs b/src/Orchard.Web/Core/Routable/ViewModels/RoutableEditorViewModel.cs index 4bdefc198..8f6b4e043 100644 --- a/src/Orchard.Web/Core/Routable/ViewModels/RoutableEditorViewModel.cs +++ b/src/Orchard.Web/Core/Routable/ViewModels/RoutableEditorViewModel.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; namespace Orchard.Core.Routable.ViewModels { public class RoutableEditorViewModel { @@ -15,6 +14,6 @@ namespace Orchard.Core.Routable.ViewModels { public int? ContainerId { get; set; } public bool PromoteToHomePage { get; set; } - public string DisplayLeadingPath { get; set; } + public string ContainerAbsoluteUrl { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Routable/Views/EditorTemplates/Parts/Routable.RoutePart.cshtml b/src/Orchard.Web/Core/Routable/Views/EditorTemplates/Parts/Routable.RoutePart.cshtml index 51c226dde..195d54bf6 100644 --- a/src/Orchard.Web/Core/Routable/Views/EditorTemplates/Parts/Routable.RoutePart.cshtml +++ b/src/Orchard.Web/Core/Routable/Views/EditorTemplates/Parts/Routable.RoutePart.cshtml @@ -7,7 +7,7 @@ @Html.TextBoxFor(m => m.Title, new { @class = "large text" })