only shows the domain specific URL for language variants.
This commit is contained in:
@@ -293,8 +293,12 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
display.MasterDocId = variantDef.MasterDocId;
|
||||
|
||||
//we want to change the URL property because it shouldn't show urls if it's a variant, the URL will be specific
|
||||
//We want to change the URL property because it shouldn't show urls if it's a variant, the URL will be specific
|
||||
// to the master doc - if it is NOT a language variant.
|
||||
//For language variants the URL should only reflect the one assigned by domain.
|
||||
|
||||
var genericTab = display.Tabs.Single(x => x.Id == 0);
|
||||
var urlProp = genericTab.Properties.Single(x => x.Alias == string.Format("{0}urls", Constants.PropertyEditors.InternalGenericPropertiesPrefix));
|
||||
|
||||
var assignedLanguages = GetAssignedLanguageVariants(display);
|
||||
if (assignedLanguages.Contains(variantDef.Key) == false)
|
||||
@@ -302,14 +306,16 @@ namespace Umbraco.Web.Models.Mapping
|
||||
//it's not a language, so remove the url
|
||||
|
||||
//TODO: show a message? or just remove the prop?
|
||||
//var labelEditor = PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias).ValueEditor.View;
|
||||
var genericTab = display.Tabs.Single(x => x.Id == 0);
|
||||
var urlProp = genericTab.Properties.Single(x => x.Alias == string.Format("{0}urls", Constants.PropertyEditors.InternalGenericPropertiesPrefix));
|
||||
genericTab.Properties = genericTab.Properties.Except(new[] { urlProp });
|
||||
//var labelEditor = PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias).ValueEditor.View;
|
||||
genericTab.Properties = genericTab.Properties.Except(new[] {urlProp});
|
||||
//urlProp.Value = "The URL is the same as the master doc, custom variants do not have different URLs";
|
||||
//urlProp.Label = "";
|
||||
//urlProp.View = labelEditor;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//it is a language so filter the URLs to the specific one
|
||||
urlProp.Value = content.GetContentUrl();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
using umbraco;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
namespace Umbraco.Web.Routing
|
||||
{
|
||||
internal static class UrlProviderExtensions
|
||||
{
|
||||
public static string GetContentUrl(this IContent content, IUser user, UrlProvider urlProvider)
|
||||
{
|
||||
if (content.HasPublishedVersion() == false)
|
||||
{
|
||||
return ui.Text("content", "itemNotPublished", user);
|
||||
}
|
||||
|
||||
return urlProvider.GetUrl(content.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the URLs for the content item
|
||||
/// Returns the single url for the content item
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Use this when displaying URLs, if there are errors genertaing the urls the urls themselves will
|
||||
/// contain the errors.
|
||||
/// </remarks>
|
||||
public static IEnumerable<string> GetContentUrls(this IContent content)
|
||||
public static string GetContentUrl(this IContent content)
|
||||
{
|
||||
return content.GetContentUrl(
|
||||
UmbracoContext.Current.Security.CurrentUser,
|
||||
UmbracoContext.Current.RoutingContext.UrlProvider);
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetContentUrls(this IContent content, IUser user, UrlProvider urlProvider)
|
||||
{
|
||||
var urls = new List<string>();
|
||||
|
||||
if (content.HasPublishedVersion() == false)
|
||||
{
|
||||
urls.Add(ui.Text("content", "itemNotPublished", UmbracoContext.Current.Security.CurrentUser));
|
||||
urls.Add(ui.Text("content", "itemNotPublished", user));
|
||||
return urls;
|
||||
}
|
||||
|
||||
var urlProvider = UmbracoContext.Current.RoutingContext.UrlProvider;
|
||||
var url = urlProvider.GetUrl(content.Id);
|
||||
var url = urlProvider.GetUrl(content.Id);
|
||||
if (url == "#")
|
||||
{
|
||||
// document as a published version yet it's url is "#" => a parent must be
|
||||
@@ -39,9 +53,9 @@ namespace Umbraco.Web.Routing
|
||||
while (parent != null && parent.Published);
|
||||
|
||||
if (parent == null) // oops - internal error
|
||||
urls.Add(ui.Text("content", "parentNotPublishedAnomaly", UmbracoContext.Current.Security.CurrentUser));
|
||||
urls.Add(ui.Text("content", "parentNotPublishedAnomaly", user));
|
||||
else
|
||||
urls.Add(ui.Text("content", "parentNotPublished", parent.Name, UmbracoContext.Current.Security.CurrentUser));
|
||||
urls.Add(ui.Text("content", "parentNotPublished", parent.Name, user));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -50,5 +64,21 @@ namespace Umbraco.Web.Routing
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the URLs for the content item
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Use this when displaying URLs, if there are errors genertaing the urls the urls themselves will
|
||||
/// contain the errors.
|
||||
/// </remarks>
|
||||
public static IEnumerable<string> GetContentUrls(this IContent content)
|
||||
{
|
||||
return content.GetContentUrls(
|
||||
UmbracoContext.Current.Security.CurrentUser,
|
||||
UmbracoContext.Current.RoutingContext.UrlProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user