mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Updating the RoutePart slug prefix display in the editor to cope with not being in a vdir.
Related to #16496 which was already fixed a w/ another bug a little earlier but a double '/' appears when the app is not in a vdir. work item: 16496 --HG-- branch : dev
This commit is contained in:
@@ -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<RoutePart> {
|
||||
private readonly IOrchardServices _services;
|
||||
private readonly IRoutableService _routableService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IHomePageProvider _routableHomePageProvider;
|
||||
|
||||
public RoutePartDriver(IOrchardServices services, IRoutableService routableService, IEnumerable<IHomePageProvider> homePageProviders) {
|
||||
public RoutePartDriver(IOrchardServices services,
|
||||
IRoutableService routableService,
|
||||
IEnumerable<IHomePageProvider> 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",
|
||||
|
@@ -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; }
|
||||
}
|
||||
}
|
@@ -7,7 +7,7 @@
|
||||
@Html.TextBoxFor(m => m.Title, new { @class = "large text" })
|
||||
</fieldset>
|
||||
<fieldset class="permalink">
|
||||
<label class="sub" for="Slug">@T("Permalink")<br /><span>@Request.ToApplicationRootUrlString()/@Model.DisplayLeadingPath</span></label>
|
||||
<label class="sub" for="Slug">@T("Permalink")<br /><span>@Model.ContainerAbsoluteUrl/</span></label>
|
||||
<span>@Html.TextBoxFor(m => m.Slug, new { @class = "text" })</span>
|
||||
<span class="checkbox-and-label">
|
||||
@Html.EditorFor(m => m.PromoteToHomePage)
|
||||
|
Reference in New Issue
Block a user