-
Notifications
You must be signed in to change notification settings - Fork 811
Umbraco 15.2 release documentation updates #6808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
714137b
Added details of content type filters.
AndyButland 8e360c6
Linting
AndyButland 199e4e2
Updated page for 14
AndyButland 8592fca
docs: adds new condition type `Umb.Condition.CurrentUser.GroupId`
iOvergaard f623172
Merge branch 'main' into cms/release-15.2
AndyButland 393cec0
Adds `BackOfficeLogo` to the `ContentSettings` (#6836)
leekelleher cd75b24
Minor formatting
sofietoft 998e20c
Update contentsettings.md
sofietoft b461fcc
Updated some grammar etc
sofietoft 5a5f6a4
Merge branch 'main' into cms/release-15.2
sofietoft c7887b4
Update 15/umbraco-cms/reference/content-type-filters.md
sofietoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| --- | ||
| description: Describes how to use Content Type Filters to restrict the allowed content options available to editors. | ||
| --- | ||
|
|
||
| # Filtering Allowed Content Types | ||
|
|
||
| When content editors add new content they are presented with a dialog where they must select the type of content they want to create. The options available are defined when setting up the Document, Media, and Member types in the **Settings** section. | ||
|
|
||
| Implementors and package creators can add additional logic to determine which options are available to the editors. | ||
|
|
||
| This is possible using Content Type Filters. | ||
|
|
||
| {% hint style="info" %} | ||
| The use cases supported here are similar to those where the `SendingAllowedChildrenNotification` would be used in Umbraco 13 or earlier. | ||
| {% endhint %} | ||
|
|
||
| ## Implementing a Content Type Filter | ||
|
|
||
| To create a Content Type Filter you use a class that implements the `IContentTypeFilter` interface (found in the `Umbraco.Cms.Core.Services.Filters` namespace). | ||
|
|
||
| There are two methods you can implement: | ||
|
|
||
| * One for filtering the content types allowed at the content root | ||
| * One for the content types allowed below a given parent node. | ||
|
|
||
| If you don't want to filter using one of the two approaches, you can return the provided collection unmodified. | ||
|
|
||
| ### Example Use Case | ||
|
|
||
| The following example shows a typical use case. Often websites will have a "Home Page" Document Type which is created at the root. Normally, only one of these is required. You can enforce that using the following Content Type Filter. | ||
|
|
||
| The code below is querying the existing content available at the root. Normally you can create a "Home Page" here, but if one already exists that option is removed: | ||
|
|
||
| ```csharp | ||
| internal class OneHomePageOnlyContentTypeFilter : IContentTypeFilter | ||
| { | ||
| private readonly IContentService _contentService; | ||
|
|
||
| public OneHomePageOnlyContentTypeFilter(IContentService contentService) => _contentService = contentService; | ||
|
|
||
| public Task<IEnumerable<TItem>> FilterAllowedAtRootAsync<TItem>(IEnumerable<TItem> contentTypes) | ||
| where TItem : IContentTypeComposition | ||
| { | ||
| var docTypeAliasesToExclude = new List<string>(); | ||
|
|
||
| const string HomePageDocTypeAlias = "homePage"; | ||
| var docTypeAliasesAtRoot = _contentService.GetRootContent() | ||
| .Select(x => x.ContentType.Alias) | ||
| .Distinct() | ||
| .ToList(); | ||
| if (docTypeAliasesAtRoot.Contains(HomePageDocTypeAlias)) | ||
| { | ||
| docTypeAliasesToExclude.Add(HomePageDocTypeAlias); | ||
| } | ||
|
|
||
| return Task.FromResult(contentTypes | ||
| .Where(x => docTypeAliasesToExclude.Contains(x.Alias) is false)); | ||
| } | ||
|
|
||
| public Task<IEnumerable<ContentTypeSort>> FilterAllowedChildrenAsync(IEnumerable<ContentTypeSort> contentTypes, Guid parentKey) | ||
| => Task.FromResult(contentTypes); | ||
| } | ||
| ``` | ||
|
|
||
| Content Type Filters are registered as a collection, making it possible to have more than one in the solution or an installed package. | ||
|
|
||
| The filters need to be registered in a composer: | ||
|
|
||
| ```csharp | ||
| public class MyComposer : IComposer | ||
| { | ||
| public void Compose(IUmbracoBuilder builder) | ||
| { | ||
| builder.ContentTypeFilters() | ||
| .Append<OneHomePageOnlyContentTypeFilter>(); | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.