Created
March 15, 2022 23:44
-
-
Save JasonElkin/55b6e3a8610ed9c9b10850bd94438c83 to your computer and use it in GitHub Desktop.
Enable non-unique node names based on parent content type in Umbraco v9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomDocumentRepository : DocumentRepository | |
{ | |
private static readonly string[] allowNonUniqueChildNames = { EventsPage.ModelTypeAlias, NewsPage.ModelTypeAlias }; | |
public CustomDocumentRepository( | |
IScopeAccessor scopeAccessor, | |
AppCaches appCaches, | |
ILogger<DocumentRepository> logger, | |
ILoggerFactory loggerFactory, | |
IContentTypeRepository contentTypeRepository, | |
ITemplateRepository templateRepository, | |
ITagRepository tagRepository, | |
ILanguageRepository languageRepository, | |
IRelationRepository relationRepository, | |
IRelationTypeRepository relationTypeRepository, | |
PropertyEditorCollection propertyEditors, | |
DataValueReferenceFactoryCollection dataValueReferenceFactories, | |
IDataTypeService dataTypeService, | |
IJsonSerializer serializer, | |
IEventAggregator eventAggregator) : base(scopeAccessor, appCaches, logger, loggerFactory, contentTypeRepository, templateRepository, tagRepository, languageRepository, relationRepository, relationTypeRepository, propertyEditors, dataValueReferenceFactories, dataTypeService, serializer, eventAggregator) | |
{ | |
} | |
protected override string EnsureUniqueNodeName(int parentId, string nodeName, int id = 0) | |
{ | |
var parent = this.Get(parentId); | |
if (allowNonUniqueChildNames.InvariantContains(parent.ContentType.Alias)) | |
{ | |
return nodeName; | |
} | |
return base.EnsureUniqueNodeName(parentId, nodeName, id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment