You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 15/umbraco-cms/reference/content-type-filters.md
+15-10Lines changed: 15 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,27 +4,32 @@ description: Describes how to use Content Type Filters to restrict the allowed c
4
4
5
5
# Filtering Allowed Content Types
6
6
7
-
When creating content editors are presented with a dialog where they 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.
7
+
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.
8
8
9
-
Sometimes implementors or packages have a requirement to use some additional logic to determine which options are available.
9
+
Implementors and package creators can add additional logic to determine which options are available to the editors.
10
10
11
-
This is possible using content type filters.
11
+
This is possible using Content Type Filters.
12
12
13
13
{% hint style="info" %}
14
-
The uses cases supported here are similar to those where the `SendingAllowedChildrenNotification` would be used in Umbraco 13 or earlier.
14
+
The use cases supported here are similar to those where the `SendingAllowedChildrenNotification` would be used in Umbraco 13 or earlier.
15
15
{% endhint %}
16
16
17
17
## Implementing a Content Type Filter
18
18
19
-
To create a content type filter you use a class that implements the `IContentTypeFilter` interface (found in the `Umbraco.Cms.Core.Services.Filters` namespace).
19
+
To create a Content Type Filter you use a class that implements the `IContentTypeFilter` interface (found in the `Umbraco.Cms.Core.Services.Filters` namespace).
20
20
21
-
There are two methods you can implement. One is for filtering the content types allowed at the content root. The other is for the content types allowed below a given parent node.
21
+
There are two methods you can implement:
22
22
23
-
If you don't want to filter for one or other method, you can return the provided collection unmodified.
23
+
* One for filtering the content types allowed at the content root
24
+
* One for the content types allowed below a given parent node.
25
+
26
+
If you don't want to filter using one of the two approaches, you can return the provided collection unmodified.
27
+
28
+
### Example Use case
24
29
25
30
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.
26
31
27
-
Here we are querying the existing content available at the root. Normally we can create a "Home Page" here, but if one already exists, we remove the option:
32
+
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:
0 commit comments