Gets the variant names working in the editor
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using AutoMapper;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using ContentVariation = Umbraco.Core.Models.ContentVariation;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to map the <see cref="ContentItemDisplay"/> name from an <see cref="IContent"/> depending on it's variation settings
|
||||
/// </summary>
|
||||
internal class ContentItemDisplayNameResolver : IValueResolver<IContent, ContentItemDisplay, string>
|
||||
{
|
||||
public string Resolve(IContent source, ContentItemDisplay destination, string destMember, ResolutionContext context)
|
||||
{
|
||||
var langId = context.GetLanguageId();
|
||||
if (langId.HasValue && source.ContentType.Variations.HasFlag(ContentVariation.CultureNeutral))
|
||||
{
|
||||
//return the culture name being requested
|
||||
return source.GetName(langId);
|
||||
}
|
||||
|
||||
return source.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user