Skip to content

Commit 199e4e2

Browse files
committed
Updated page for 14
1 parent 8e360c6 commit 199e4e2

File tree

1 file changed

+2
-78
lines changed

1 file changed

+2
-78
lines changed

14/umbraco-cms/reference/notifications/sendingallowedchildrennotifications.md

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,6 @@ description: Example of how to use a SendingAllowedChildren Notification
44

55
# Sending Allowed Children Notification
66

7-
The `SendingAllowedChildrenNotification` enables you to manipulate the Document Types that will be shown in the create menu when adding new content in the backoffice.
7+
The `SendingAllowedChildrenNotification` is no longer available in Umbraco 14 and no replacement is available for this major version.
88

9-
## Usage
10-
11-
With the example below we can ensure that a Document Type cannot be selected if the type already exists in the Content tree.
12-
13-
```csharp
14-
using System.Web;
15-
using Umbraco.Cms.Core.Events;
16-
using Umbraco.Cms.Core.Notifications;
17-
18-
namespace Umbraco.Docs.Samples.Web.Notifications;
19-
20-
public class SendingAllowedChildrenNotificationHandler : INotificationHandler<SendingAllowedChildrenNotification>
21-
{
22-
public void Handle(SendingAllowedChildrenNotification notification)
23-
{
24-
const string contentIdKey = "contentId";
25-
26-
// Try get the id from the content item in the backoffice
27-
var queryStringCollection = HttpUtility.ParseQueryString(notification.UmbracoContext.OriginalRequestUrl.Query);
28-
29-
if (!queryStringCollection.ContainsKey(contentIdKey))
30-
{
31-
return;
32-
}
33-
34-
var contentId = queryStringCollection[contentIdKey].TryConvertTo<int>().ResultOr(-1);
35-
36-
if (contentId == -1)
37-
{
38-
return;
39-
}
40-
41-
var content = notification.UmbracoContext.Content?.GetById(true, contentId);
42-
43-
if (content is null)
44-
{
45-
return;
46-
}
47-
48-
// Allowed children as configured in the backoffice
49-
var allowedChildren = notification.Children.ToList();
50-
51-
if (content.ChildrenForAllCultures is not null)
52-
{
53-
// Get all children of current page
54-
var childNodes = content.ChildrenForAllCultures.ToList();
55-
56-
// If there is a Settings page already created, then don't allow it anymore
57-
// You can also use the ModelTypeAlias property from your PublishedModel for comparison,
58-
// like Settings.ModelTypeAlias if you have set models builder to generate SourceCode models
59-
if (childNodes.Any(x => x.ContentType.Alias == "settings"))
60-
{
61-
allowedChildren.RemoveAll(x => x.Alias == "settings");
62-
}
63-
}
64-
65-
// Update the allowed children
66-
notification.Children = allowedChildren;
67-
}
68-
}
69-
```
70-
71-
You also need to register this notification handler. You can achieve this by updating the `Program` class like:
72-
73-
```csharp
74-
builder.CreateUmbracoBuilder()
75-
.AddBackOffice()
76-
.AddWebsite()
77-
.AddDeliveryApi()
78-
.AddComposers()
79-
.AddNotificationHandler<SendingAllowedChildrenNotification, SendingAllowedChildrenNotificationHandler>()
80-
.Build();
81-
```
82-
83-
{% hint style="info" %}
84-
For more information about registering notifications read the [Registering notification handlers](./) article.
85-
{% endhint %}
9+
Please see [content type filters](../../../../15/umbraco-cms/reference/content-type-filters.md) as the supported alternative in Umbraco 15 for use cases that previously relied on this notification.

0 commit comments

Comments
 (0)