diff --git a/15/umbraco-cms/SUMMARY.md b/15/umbraco-cms/SUMMARY.md index 870a264f122..8081e852625 100644 --- a/15/umbraco-cms/SUMMARY.md +++ b/15/umbraco-cms/SUMMARY.md @@ -371,8 +371,6 @@ * [UserService Notifications Example](reference/notifications/userservice-notifications.md) * [Sending Allowed Children Notification](reference/notifications/sendingallowedchildrennotifications.md) * [Umbraco Application Lifetime Notifications](reference/notifications/umbracoapplicationlifetime-notifications.md) - * [EditorModel Notifications](reference/notifications/editormodel-notifications/README.md) - * [Customizing the "Links" box](reference/notifications/editormodel-notifications/customizing-the-links-box.md) * [Hot vs. cold restarts](reference/notifications/hot-vs-cold-restarts.md) * [Inversion of Control / Dependency injection](reference/using-ioc.md) * [Management](reference/management/README.md) diff --git a/15/umbraco-cms/reference/notifications/README.md b/15/umbraco-cms/reference/notifications/README.md index 79ba4613979..8dd4ad60a0e 100644 --- a/15/umbraco-cms/reference/notifications/README.md +++ b/15/umbraco-cms/reference/notifications/README.md @@ -263,14 +263,6 @@ Below you can find a list of the most common UmbracoApplicationLifetime object n Learn more about these under [Tree Change Notifications](https://apidocs.umbraco.com/v15/csharp/api/Umbraco.Cms.Core.Notifications.TreeChangeNotification-1.html) in the CMS API Docs. -### Editor Model Notifications - -See [EditorModel Notifications](editormodel-notifications/) for a list of the EditorModel events. - -{% hint style="info" %} -Useful for manipulating the model before it is sent to an editor in the backoffice. It could be used to set a default value of a property on a new document. -{% endhint %} - ## Creating and publishing your own custom notifications Umbraco uses notifications to allow people to hook into different workflow processes. This notification pattern is extensible, allowing you to create and publish custom notifications, and other people to observe and hook into your custom processes. This approach can be useful when creating Umbraco packages. For more information on how you create and publish your own notifications, see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. diff --git a/15/umbraco-cms/reference/notifications/editormodel-notifications/README.md b/15/umbraco-cms/reference/notifications/editormodel-notifications/README.md deleted file mode 100644 index 23dc06c26aa..00000000000 --- a/15/umbraco-cms/reference/notifications/editormodel-notifications/README.md +++ /dev/null @@ -1,168 +0,0 @@ -# EditorModel Notifications - -{% hint style="warning" %} -This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice. - -EditorModel notifications are no longer handled on the server-side, but on the client-side. As the documentation effort progresses, the samples on this page will be updated accordingly. -{% endhint %} - -EditorModel notifications enable you to manipulate the model used by the backoffice before it is loaded into an editor. For example the `SendingContentNotification` is published right before a content item is loaded into the backoffice for editing. It is therefore the perfect notification to use to set a default value for a particular property, or perhaps to hide a property/tab/Content App from a certain editor. - -## Usage - -Example usage of the `SendingContentNotification` - e.g. set the default PublishDate for a new NewsArticle to be today's Date: - -{% code overflow="wrap" lineNumbers="true" fullWidth="false" %} -```csharp -using System; -using System.Linq; -using Umbraco.Cms.Core.Events; -using Umbraco.Cms.Core.Models.ContentEditing; -using Umbraco.Cms.Core.Notifications; -using Umbraco.Extensions; - -namespace Umbraco.Docs.Samples.Web.Notifications; - -public class EditorSendingContentNotificationHandler : INotificationHandler -{ - public void Handle(SendingContentNotification notification) - { - if (notification.Content.ContentTypeAlias.Equals("blogpost")) - { - // Access the property you want to pre-populate - // each content item can have 'variations' - each variation is represented by the `ContentVariantDisplay` class. - // if your site uses variants, then you need to decide whether to set the default value for all variants or a specific variant - // eg. set by variant name: - // var variant = notification.Content.Variants.FirstOrDefault(f => f.Name == "specificVariantName"); - // OR loop through all the variants: - foreach (var variant in notification.Content.Variants) - { - // Check if variant is a 'new variant' - // we only want to set the default value when the content item is first created - if (variant.State == ContentSavedState.NotCreated) - { - // each variant has an IEnumerable of 'Tabs' (property groupings) - // and each of these contain an IEnumerable of `ContentPropertyDisplay` properties - // find the first property with alias 'publishDate' - var pubDateProperty = variant.Tabs.SelectMany(f => f.Properties) - .FirstOrDefault(f => f.Alias.InvariantEquals("publishDate")); - if (pubDateProperty is not null) - { - // set default value of the publish date property if it exists - pubDateProperty.Value = DateTime.UtcNow; - } - } - } - } - } -} -``` -{% endcode %} - -Another example could be to set the default Member Group for a specific Member Type using `SendingMemberNotification`: - -```csharp -using System.Collections.Generic; -using System.Linq; -using Umbraco.Cms.Core; -using Umbraco.Cms.Core.Events; -using Umbraco.Cms.Core.Notifications; -using Umbraco.Cms.Core.Services; - -namespace Umbraco.Docs.Samples.Web.Notifications; - -public class EditorSendingMemberNotificationHandler : INotificationHandler -{ - private readonly IMemberGroupService _memberGroupService; - - public EditorSendingMemberNotificationHandler(IMemberGroupService memberGroupService) - { - _memberGroupService = memberGroupService; - } - - public void Handle(SendingMemberNotification notification) - { - var isNew = !int.TryParse(notification.Member.Id?.ToString(), out int id) || id == 0; - - // We only want to set the default member group when the member is initially created, eg doesn't have an Id yet - if (isNew is false) - { - return; - } - - // Set a default value member group for the member type `Member` - if (notification.Member.ContentTypeAlias.Equals("Member")) - { - var memberGroup = _memberGroupService.GetByName("Customer"); - if (memberGroup is null) - { - return; - } - - // Find member group property on member model - var property = notification.Member.MembershipProperties.FirstOrDefault(x => - x.Alias.Equals($"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}membergroup")); - - if (property is not null) - { - // Assign a default value for member group property - property.Value = new Dictionary - { - {memberGroup.Name, true} - }; - } - } - } -} -``` - -## Notifications - -| Notification | Members | Description | -| ---------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| SendingContentNotification |
  • ContentItemDisplay Content
  • IUmbracoContext UmbracoContext
|

Published right before the editor model is sent for editing in the content section.
NOTE: Content is a Umbraco.Cms.Core.Models.ContentEditing.ContentItemDisplay type which contains the tabs and properties of the elements about to be loaded for editing.

| -| SendingMediaNotification |
  • MediaItemDisplay Media
  • IUmbracoContext UmbracoContext
|

Published right before the editor model is sent for editing in the media section
NOTE: Media is a Umbraco.Cms.Core.Models.ContentEditing.MediaItemDisplay type which in turn contains the tabs and properties of the elements about to be loaded for editing.

| -| SendingMemberNotification |
  • MemberDisplay Member
  • IUmbracoContext UmbracoContext
|

Published right before the editor model is sent for editing in the member section.
NOTE: Member is a Umbraco.Cms.Core.Models.ContentEditing.MemberDisplay type which in turn contains the tabs and properties of the elements about to be loaded for editing.

| -| SendingUserNotification |
  • UserDisplay User
  • IUmbracoContext UmbracoContext
|

Published right before the editor model is sent for editing in the user section.
NOTE: User is a Umbraco.Cms.Core.Models.ContentEditing.UserDisplay type which in turn contains the tabs and properties of the elements about to be loaded for editing.

| -| SendingDashboardsNotification |
  • IEnumerable<Tab<IDashboardSlim>> Dashboards
  • IUmbracoContext UmbracoContext
|

Published right before the a dashboard is retrieved in a section.
NOTE: Dashboards is a collection of IDashboardSlim, each object gives you access to Label, Alias, Properties, whether it's expanded, and whether it IsActive.

| -| SendingAllowedChildrenNotification |
  • IEnumerable<ContentTypeBasic> Children
  • IUmbracoContext UmbracoContext
|

Published right before the allowed children of the selected Content Type are sent back during content creation in the Content Section.
NOTE: Children is a collection of ContentTypeBasic, each object gives you access to Alias, Description, Thumbnail and more. You can remove or add new children to the list in the notification.

| - -### Display models - -#### ContentItemDisplay - -A model representing a content item to be displayed in the backoffice - -* TemplateAlias -* Urls -* AllowPreview - Determines whether previewing is allowed for this node, By default this is true but by using notifications developers can toggle this off for certain documents if there is nothing to preview -* AllowedActions - The allowed 'actions' based on the user's permissions - Create, Update, Publish, Send to publish -* IsBlueprint -* Tabs - Defines the tabs containing display properties -* Properties - properties based on the properties in the tabs collection -* And more... - -#### MediaItemDisplay - -A model representing a media item to be displayed in the backoffice - -* Alias -* Tabs - Defines the tabs containing display properties -* Properties - properties based on the properties in the tabs collection -* And more... - -#### MemberDisplay - -A model representing a member to be displayed in the backoffice - -* Username -* Email -* Tabs - Defines the tabs containing display properties -* Properties - properties based on the properties in the tabs collection -* And more... - -## Samples - -The EditorModel notifications gives you a lot of options to customize the backoffice experience. You can find inspiration from the various samples provided below: - -* [Customizing the "Links" box](customizing-the-links-box.md) diff --git a/15/umbraco-cms/reference/notifications/editormodel-notifications/customizing-the-links-box.md b/15/umbraco-cms/reference/notifications/editormodel-notifications/customizing-the-links-box.md deleted file mode 100644 index 359db99af67..00000000000 --- a/15/umbraco-cms/reference/notifications/editormodel-notifications/customizing-the-links-box.md +++ /dev/null @@ -1,39 +0,0 @@ -# Customizing the "Links" box - -For a content item, Umbraco will show a **Links** box within the **Info** content app. By default, this box will show one or more links to content item. - -![Links Box](images/properties-info-app-v14.png) - -With the `SendingContentNotification` event, we can manipulate the links in the `Urls` property. This could be by replacing it with custom links although a URL provider would be more suitable: - -```csharp -public void Handle(SendingContentNotification notification) -{ - notification.Content.Urls = new[] - { - new UrlInfo($"/products/?id={notification.Content.Id}", true, null) - }; -} -``` - -If the content item has multiple cultures, we can specify the link culture like this: - -```csharp -public void Handle(SendingContentNotification notification) -{ - notification.Content.Urls = new[] - { - new UrlInfo($"https://mysite.com/products/?id={notification.Content.Id}", true, "en-US"), - new UrlInfo($"https://mysite.dk/produkter/?id={notification.Content.Id}", true, "da-DK") - }; -} -``` - -or remove the box entirely by providing an empty list of links: - -```csharp -public void Handle(SendingContentNotification notification) -{ - notification.Content.Urls = null; -} -``` diff --git a/15/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app-v14.png b/15/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app-v14.png deleted file mode 100644 index e9525c9a306..00000000000 Binary files a/15/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app-v14.png and /dev/null differ diff --git a/15/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app.png b/15/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app.png deleted file mode 100644 index 3af83b41b26..00000000000 Binary files a/15/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app.png and /dev/null differ diff --git a/16/umbraco-cms/reference/notifications/README.md b/16/umbraco-cms/reference/notifications/README.md index b4eae548857..65479ff8d7a 100644 --- a/16/umbraco-cms/reference/notifications/README.md +++ b/16/umbraco-cms/reference/notifications/README.md @@ -263,14 +263,6 @@ Below you can find a list of the most common UmbracoApplicationLifetime object n Learn more about these under [Tree Change Notifications](https://apidocs.umbraco.com/v15/csharp/api/Umbraco.Cms.Core.Notifications.TreeChangeNotification-1.html) in the CMS API Docs. -### Editor Model Notifications - -See [EditorModel Notifications](editormodel-notifications/) for a list of the EditorModel events. - -{% hint style="info" %} -Useful for manipulating the model before it is sent to an editor in the backoffice. It could be used to set a default value of a property on a new document. -{% endhint %} - ## Creating and publishing your own custom notifications Umbraco uses notifications to allow people to hook into different workflow processes. This notification pattern is extensible, allowing you to create and publish custom notifications, and other people to observe and hook into your custom processes. This approach can be useful when creating Umbraco packages. For more information on how you create and publish your own notifications, see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. diff --git a/17/umbraco-cms/.gitbook.yaml b/17/umbraco-cms/.gitbook.yaml index 15a796d982f..41d7d74474c 100644 --- a/17/umbraco-cms/.gitbook.yaml +++ b/17/umbraco-cms/.gitbook.yaml @@ -17,7 +17,6 @@ redirects: customizing/foundation/working-with-data/repositories: customizing/foundation/repositories.md customizing/foundation/working-with-data/states: customizing/foundation/states.md customizing/foundation/working-with-data/store: customizing/foundation/README.md - reference/notifications/editormodel-notifications/customizing-the-links-box: reference/notifications/editormodel-notifications/README.md fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/blocks: fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md tutorials/creating-a-custom-dashboard: tutorials/creating-a-custom-dashboard/README.md extending/property-editors/declaring-your-property-editor: tutorials/creating-a-property-editor/README.md diff --git a/17/umbraco-cms/SUMMARY.md b/17/umbraco-cms/SUMMARY.md index 559e4a7b771..cde206ffa87 100644 --- a/17/umbraco-cms/SUMMARY.md +++ b/17/umbraco-cms/SUMMARY.md @@ -377,7 +377,6 @@ * [MediaService Notifications Example](reference/notifications/mediaservice-notifications.md) * [MemberService Notifications Example](reference/notifications/memberservice-notifications.md) * [Umbraco Application Lifetime Notifications](reference/notifications/umbracoapplicationlifetime-notifications.md) - * [EditorModel Notifications](reference/notifications/editormodel-notifications/README.md) * [Hot vs. cold restarts](reference/notifications/hot-vs-cold-restarts.md) * [Inversion of Control / Dependency injection](reference/using-ioc.md) * [Management](reference/management/README.md) diff --git a/17/umbraco-cms/reference/notifications/README.md b/17/umbraco-cms/reference/notifications/README.md index b4eae548857..65479ff8d7a 100644 --- a/17/umbraco-cms/reference/notifications/README.md +++ b/17/umbraco-cms/reference/notifications/README.md @@ -263,14 +263,6 @@ Below you can find a list of the most common UmbracoApplicationLifetime object n Learn more about these under [Tree Change Notifications](https://apidocs.umbraco.com/v15/csharp/api/Umbraco.Cms.Core.Notifications.TreeChangeNotification-1.html) in the CMS API Docs. -### Editor Model Notifications - -See [EditorModel Notifications](editormodel-notifications/) for a list of the EditorModel events. - -{% hint style="info" %} -Useful for manipulating the model before it is sent to an editor in the backoffice. It could be used to set a default value of a property on a new document. -{% endhint %} - ## Creating and publishing your own custom notifications Umbraco uses notifications to allow people to hook into different workflow processes. This notification pattern is extensible, allowing you to create and publish custom notifications, and other people to observe and hook into your custom processes. This approach can be useful when creating Umbraco packages. For more information on how you create and publish your own notifications, see the [creating and publishing notifications](creating-and-publishing-notifications.md) article. diff --git a/17/umbraco-cms/reference/notifications/editormodel-notifications/README.md b/17/umbraco-cms/reference/notifications/editormodel-notifications/README.md deleted file mode 100644 index 17023188509..00000000000 --- a/17/umbraco-cms/reference/notifications/editormodel-notifications/README.md +++ /dev/null @@ -1,168 +0,0 @@ -# EditorModel Notifications - -{% hint style="warning" %} -This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice. - -EditorModel notifications are no longer handled on the server-side, but on the client-side. As the documentation effort progresses, the samples on this page will be updated accordingly. -{% endhint %} - -EditorModel notifications enable you to manipulate the model used by the backoffice before it is loaded into an editor. For example the `SendingContentNotification` is published right before a content item is loaded into the backoffice for editing. It is therefore the perfect notification to use to set a default value for a particular property, or perhaps to hide a property/tab/Content App from a certain editor. - -## Usage - -Example usage of the `SendingContentNotification` - e.g. set the default PublishDate for a new NewsArticle to be today's Date: - -{% code overflow="wrap" lineNumbers="true" fullWidth="false" %} -```csharp -using System; -using System.Linq; -using Umbraco.Cms.Core.Events; -using Umbraco.Cms.Core.Models.ContentEditing; -using Umbraco.Cms.Core.Notifications; -using Umbraco.Extensions; - -namespace Umbraco.Docs.Samples.Web.Notifications; - -public class EditorSendingContentNotificationHandler : INotificationHandler -{ - public void Handle(SendingContentNotification notification) - { - if (notification.Content.ContentTypeAlias.Equals("blogpost")) - { - // Access the property you want to pre-populate - // each content item can have 'variations' - each variation is represented by the `ContentVariantDisplay` class. - // if your site uses variants, then you need to decide whether to set the default value for all variants or a specific variant - // eg. set by variant name: - // var variant = notification.Content.Variants.FirstOrDefault(f => f.Name == "specificVariantName"); - // OR loop through all the variants: - foreach (var variant in notification.Content.Variants) - { - // Check if variant is a 'new variant' - // we only want to set the default value when the content item is first created - if (variant.State == ContentSavedState.NotCreated) - { - // each variant has an IEnumerable of 'Tabs' (property groupings) - // and each of these contain an IEnumerable of `ContentPropertyDisplay` properties - // find the first property with alias 'publishDate' - var pubDateProperty = variant.Tabs.SelectMany(f => f.Properties) - .FirstOrDefault(f => f.Alias.InvariantEquals("publishDate")); - if (pubDateProperty is not null) - { - // set default value of the publish date property if it exists - pubDateProperty.Value = DateTime.UtcNow; - } - } - } - } - } -} -``` -{% endcode %} - -Another example could be to set the default Member Group for a specific Member Type using `SendingMemberNotification`: - -```csharp -using System.Collections.Generic; -using System.Linq; -using Umbraco.Cms.Core; -using Umbraco.Cms.Core.Events; -using Umbraco.Cms.Core.Notifications; -using Umbraco.Cms.Core.Services; - -namespace Umbraco.Docs.Samples.Web.Notifications; - -public class EditorSendingMemberNotificationHandler : INotificationHandler -{ - private readonly IMemberGroupService _memberGroupService; - - public EditorSendingMemberNotificationHandler(IMemberGroupService memberGroupService) - { - _memberGroupService = memberGroupService; - } - - public void Handle(SendingMemberNotification notification) - { - var isNew = !int.TryParse(notification.Member.Id?.ToString(), out int id) || id == 0; - - // We only want to set the default member group when the member is initially created, eg doesn't have an Id yet - if (isNew is false) - { - return; - } - - // Set a default value member group for the member type `Member` - if (notification.Member.ContentTypeAlias.Equals("Member")) - { - var memberGroup = _memberGroupService.GetByName("Customer"); - if (memberGroup is null) - { - return; - } - - // Find member group property on member model - var property = notification.Member.MembershipProperties.FirstOrDefault(x => - x.Alias.Equals($"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}membergroup")); - - if (property is not null) - { - // Assign a default value for member group property - property.Value = new Dictionary - { - {memberGroup.Name, true} - }; - } - } - } -} -``` - -## Notifications - -| Notification | Members | Description | -| ---------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| SendingContentNotification |
  • ContentItemDisplay Content
  • IUmbracoContext UmbracoContext
|

Published right before the editor model is sent for editing in the content section.
NOTE: Content is a Umbraco.Cms.Core.Models.ContentEditing.ContentItemDisplay type which contains the tabs and properties of the elements about to be loaded for editing.

| -| SendingMediaNotification |
  • MediaItemDisplay Media
  • IUmbracoContext UmbracoContext
|

Published right before the editor model is sent for editing in the media section
NOTE: Media is a Umbraco.Cms.Core.Models.ContentEditing.MediaItemDisplay type which in turn contains the tabs and properties of the elements about to be loaded for editing.

| -| SendingMemberNotification |
  • MemberDisplay Member
  • IUmbracoContext UmbracoContext
|

Published right before the editor model is sent for editing in the member section.
NOTE: Member is a Umbraco.Cms.Core.Models.ContentEditing.MemberDisplay type which in turn contains the tabs and properties of the elements about to be loaded for editing.

| -| SendingUserNotification |
  • UserDisplay User
  • IUmbracoContext UmbracoContext
|

Published right before the editor model is sent for editing in the user section.
NOTE: User is a Umbraco.Cms.Core.Models.ContentEditing.UserDisplay type which in turn contains the tabs and properties of the elements about to be loaded for editing.

| -| SendingDashboardsNotification |
  • IEnumerable<Tab<IDashboardSlim>> Dashboards
  • IUmbracoContext UmbracoContext
|

Published right before the a dashboard is retrieved in a section.
NOTE: Dashboards is a collection of IDashboardSlim, each object gives you access to Label, Alias, Properties, whether it's expanded, and whether it IsActive.

| -| SendingAllowedChildrenNotification |
  • IEnumerable<ContentTypeBasic> Children
  • IUmbracoContext UmbracoContext
|

Published right before the allowed children of the selected Content Type are sent back during content creation in the Content Section.
NOTE: Children is a collection of ContentTypeBasic, each object gives you access to Alias, Description, Thumbnail and more. You can remove or add new children to the list in the notification.

| - -### Display models - -#### ContentItemDisplay - -A model representing a content item to be displayed in the backoffice - -* TemplateAlias -* Urls -* AllowPreview - Determines whether previewing is allowed for this node, By default this is true but by using notifications developers can toggle this off for certain documents if there is nothing to preview -* AllowedActions - The allowed 'actions' based on the user's permissions - Create, Update, Publish, Send to publish -* IsBlueprint -* Tabs - Defines the tabs containing display properties -* Properties - properties based on the properties in the tabs collection -* And more... - -#### MediaItemDisplay - -A model representing a media item to be displayed in the backoffice - -* Alias -* Tabs - Defines the tabs containing display properties -* Properties - properties based on the properties in the tabs collection -* And more... - -#### MemberDisplay - -A model representing a member to be displayed in the backoffice - -* Username -* Email -* Tabs - Defines the tabs containing display properties -* Properties - properties based on the properties in the tabs collection -* And more... - -## Samples - -The EditorModel notifications gives you a lot of options to customize the backoffice experience. You can find inspiration from the various samples provided below: - -* [Customizing the "Links" box](broken-reference) diff --git a/17/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app-v14.png b/17/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app-v14.png deleted file mode 100644 index e9525c9a306..00000000000 Binary files a/17/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app-v14.png and /dev/null differ diff --git a/17/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app.png b/17/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app.png deleted file mode 100644 index 3af83b41b26..00000000000 Binary files a/17/umbraco-cms/reference/notifications/editormodel-notifications/images/properties-info-app.png and /dev/null differ