Skip to content

Commit 577c6ff

Browse files
authored
Merge pull request #6808 from umbraco/cms/release-15.2
Umbraco 15.2 release documentation updates
2 parents f842fd4 + c7887b4 commit 577c6ff

File tree

6 files changed

+95
-157
lines changed

6 files changed

+95
-157
lines changed

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

+2-78
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.

15/umbraco-cms/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@
413413
* [Setup OAuth using Postman](reference/management-api/postman-setup-swagger.md)
414414
* [Custom Swagger API](reference/custom-swagger-api.md)
415415
* [Umbraco Flavored Markdown](reference/umbraco-flavored-markdown.md)
416+
* [Content Type Filters](reference/content-type-filters.md)
416417

417418
## Tutorials
418419

15/umbraco-cms/customizing/extending-overview/extension-conditions.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ The following conditions are available out of the box, for all extension types t
5151
* `Umb.Condition.EntityIsNotTrashed` - Requires the current entity to not be trashed.
5252
* `Umb.Condition.SectionUserPermission` - Requires the current user to have permissions to the given Section Alias.
5353
* `Umb.Condition.UserPermission.Document` - Requires the current user to have specific Document permissions. Example: 'Umb.Document.Save'.
54-
* `Umb.Condition.CurrentUser.IsAdmin` - Requires the current user to be an admin as defined by the backend, such as belonging to the Administrator group.
54+
* `Umb.Condition.CurrentUser.GroupId` - Requires the current user to belong to a specific group by GUID. Accepts `match` (GUID), `oneOf` (array), `allOf` (array), and `noneOf` (array). Example: '8d2b3c4d-4f1f-4b1f-8e3d-4a6b7b8c4f1e'.
55+
* `Umb.Condition.CurrentUser.IsAdmin` - Requires the current user to be an admin as defined by the backend, for example, that they belong to the Administrator group.
5556

5657
## Condition Configuration
5758

15/umbraco-cms/reference/configuration/contentsettings.md

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ The following snippet will give an overview of the keys and values in the conten
2626
"DisallowedUploadFiles": ["ashx", "aspx", "ascx", "config", "cshtml", "vbhtml", "asmx", "air", "axd", "xamlx"],
2727
"DisallowedUploadedFileExtensions": ["ashx", "aspx", "ascx", "config", "cshtml", "vbhtml", "asmx", "air", "axd", "xamlx"],
2828
"Error404Collection": [],
29+
"BackOfficeLogo": "../media/qyci4xti/logo.png",
30+
"HideBackOfficeLogo": false,
2931
"Imaging": {
3032
"ImageFileTypes": ["jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif"],
3133
"AutoFillImageProperties": [
@@ -127,6 +129,14 @@ If you have multiple sites, with different cultures, setup in your tree then you
127129

128130
If you have more than two sites and forget to add a 404 page and a culture, the default page will act as fallback. Same happens if you for some reason forget to define a hostname on a site.
129131

132+
### Backoffice logo
133+
134+
This setting can be used to set a custom image path to replace the Umbraco logo in the backoffice.
135+
136+
### Hide backoffice logo
137+
138+
This setting can be used to hide the Umbraco logo in backoffice.
139+
130140
### Login background image
131141

132142
You can specify your own background image for the login screen here. The image will automatically get an overlay to match backoffice colors. This path is relative to the `wwwroot/umbraco` path. The default location is: `wwwroot/umbraco/login/login.jpg`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
description: Describes how to use Content Type Filters to restrict the allowed content options available to editors.
3+
---
4+
5+
# Filtering Allowed Content Types
6+
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+
9+
Implementors and package creators can add additional logic to determine which options are available to the editors.
10+
11+
This is possible using Content Type Filters.
12+
13+
{% hint style="info" %}
14+
The use cases supported here are similar to those where the `SendingAllowedChildrenNotification` would be used in Umbraco 13 or earlier.
15+
{% endhint %}
16+
17+
## Implementing a Content Type Filter
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).
20+
21+
There are two methods you can implement:
22+
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
29+
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.
31+
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:
33+
34+
```csharp
35+
internal class OneHomePageOnlyContentTypeFilter : IContentTypeFilter
36+
{
37+
private readonly IContentService _contentService;
38+
39+
public OneHomePageOnlyContentTypeFilter(IContentService contentService) => _contentService = contentService;
40+
41+
public Task<IEnumerable<TItem>> FilterAllowedAtRootAsync<TItem>(IEnumerable<TItem> contentTypes)
42+
where TItem : IContentTypeComposition
43+
{
44+
var docTypeAliasesToExclude = new List<string>();
45+
46+
const string HomePageDocTypeAlias = "homePage";
47+
var docTypeAliasesAtRoot = _contentService.GetRootContent()
48+
.Select(x => x.ContentType.Alias)
49+
.Distinct()
50+
.ToList();
51+
if (docTypeAliasesAtRoot.Contains(HomePageDocTypeAlias))
52+
{
53+
docTypeAliasesToExclude.Add(HomePageDocTypeAlias);
54+
}
55+
56+
return Task.FromResult(contentTypes
57+
.Where(x => docTypeAliasesToExclude.Contains(x.Alias) is false));
58+
}
59+
60+
public Task<IEnumerable<ContentTypeSort>> FilterAllowedChildrenAsync(IEnumerable<ContentTypeSort> contentTypes, Guid parentKey)
61+
=> Task.FromResult(contentTypes);
62+
}
63+
```
64+
65+
Content Type Filters are registered as a collection, making it possible to have more than one in the solution or an installed package.
66+
67+
The filters need to be registered in a composer:
68+
69+
```csharp
70+
public class MyComposer : IComposer
71+
{
72+
public void Compose(IUmbracoBuilder builder)
73+
{
74+
builder.ContentTypeFilters()
75+
.Append<OneHomePageOnlyContentTypeFilter>();
76+
}
77+
}
78+
```

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

+2-78
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 15.
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](../content-type-filters.md) as the supported alternative for use cases that previously relied on this notification.

0 commit comments

Comments
 (0)