From 8572f61fee9ecf8054fdb6dd028060732b75df98 Mon Sep 17 00:00:00 2001 From: Jonathon Cove <152900831+jonathoncove2@users.noreply.github.com> Date: Thu, 31 Oct 2024 09:09:56 +0000 Subject: [PATCH 1/4] Update README.md --- 10/umbraco-cms/reference/notifications/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/10/umbraco-cms/reference/notifications/README.md b/10/umbraco-cms/reference/notifications/README.md index b9427843a06..df613753a24 100644 --- a/10/umbraco-cms/reference/notifications/README.md +++ b/10/umbraco-cms/reference/notifications/README.md @@ -275,6 +275,17 @@ Useful for manipulating the model before it is sent to an editor in the backoffi 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. +##Showing messages in the CMS + +You can inform the Umbraco user of the status of your notification by adding messages to the ```notification.Messages``` property. + +For example: +``` + notification.Messages.Add(new EventMessage("An Error occoured", + "Detail about the error", + EventMessageType.Error)); +``` + ## Samples Below you can find some articles with some examples using Notifications. From e5cb79ea4d7f9cdc035206dc48be8c4654707895 Mon Sep 17 00:00:00 2001 From: sofietoft Date: Tue, 5 Nov 2024 08:53:12 +0100 Subject: [PATCH 2/4] Apply suggestions from code review --- 10/umbraco-cms/reference/notifications/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/10/umbraco-cms/reference/notifications/README.md b/10/umbraco-cms/reference/notifications/README.md index df613753a24..6b381bdb2a4 100644 --- a/10/umbraco-cms/reference/notifications/README.md +++ b/10/umbraco-cms/reference/notifications/README.md @@ -275,11 +275,12 @@ Useful for manipulating the model before it is sent to an editor in the backoffi 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. -##Showing messages in the CMS +## Showing messages in the CMS -You can inform the Umbraco user of the status of your notification by adding messages to the ```notification.Messages``` property. +You can inform the Umbraco user of the status of your notification by adding messages to the `notification.Messages` property. For example: + ``` notification.Messages.Add(new EventMessage("An Error occoured", "Detail about the error", From e5aad9fcd271b34ad8915d2bd29db4ef862ed252 Mon Sep 17 00:00:00 2001 From: Jonathon Cove <152900831+jonathoncove2@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:29:26 +0000 Subject: [PATCH 3/4] Update README.md Added a better explanation of when to use the code --- .../reference/notifications/README.md | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/10/umbraco-cms/reference/notifications/README.md b/10/umbraco-cms/reference/notifications/README.md index 6b381bdb2a4..a5131de038b 100644 --- a/10/umbraco-cms/reference/notifications/README.md +++ b/10/umbraco-cms/reference/notifications/README.md @@ -277,14 +277,32 @@ Umbraco uses notifications to allow people to hook into different workflow proce ## Showing messages in the CMS -You can inform the Umbraco user of the status of your notification by adding messages to the `notification.Messages` property. +When handling notifications for CMS actions, you can inform the Umbraco user of the status of your notification by adding to the `notification.Messages` property within the `Handle` function. -For example: +This could be used to inform the user to an additional operation that has been performed, or alert them to an error that has occoured. + +For example, in a `ContentTypeSavedNotification`: ``` - notification.Messages.Add(new EventMessage("An Error occoured", - "Detail about the error", - EventMessageType.Error)); +public void Handle(TemplateSavedNotification notification) +{ + bool success = DoAdditionalCode(); + + if (success) + { + //on success + notification.Messages.Add(new EventMessage("Save Successful", + "The content was saved successfully", + EventMessageType.Success)); + } + else + { + //on error + notification.Messages.Add(new EventMessage("An Error occoured", + "Detail about the error", + EventMessageType.Error)); + } +} ``` ## Samples From f341617534919f0ea2c2d07f1f784b8a28649036 Mon Sep 17 00:00:00 2001 From: sofietoft Date: Mon, 2 Dec 2024 09:39:47 +0100 Subject: [PATCH 4/4] Update 10/umbraco-cms/reference/notifications/README.md --- 10/umbraco-cms/reference/notifications/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10/umbraco-cms/reference/notifications/README.md b/10/umbraco-cms/reference/notifications/README.md index a5131de038b..6579bc22e29 100644 --- a/10/umbraco-cms/reference/notifications/README.md +++ b/10/umbraco-cms/reference/notifications/README.md @@ -277,7 +277,7 @@ Umbraco uses notifications to allow people to hook into different workflow proce ## Showing messages in the CMS -When handling notifications for CMS actions, you can inform the Umbraco user of the status of your notification by adding to the `notification.Messages` property within the `Handle` function. +When handling notifications for CMS actions, you can inform the Umbraco user of the status of your notification. This is done by adding to the `notification.Messages` property within the `Handle` function. This could be used to inform the user to an additional operation that has been performed, or alert them to an error that has occoured.