Skip to content

Commit a759772

Browse files
authored
Merge pull request #6609 from jonathoncove2/patch-2
Update README.md
2 parents 808bdb1 + f341617 commit a759772

File tree

1 file changed

+30
-0
lines changed
  • 10/umbraco-cms/reference/notifications

1 file changed

+30
-0
lines changed

10/umbraco-cms/reference/notifications/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,36 @@ Useful for manipulating the model before it is sent to an editor in the backoffi
275275

276276
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.
277277

278+
## Showing messages in the CMS
279+
280+
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.
281+
282+
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.
283+
284+
For example, in a `ContentTypeSavedNotification`:
285+
286+
```
287+
public void Handle(TemplateSavedNotification notification)
288+
{
289+
bool success = DoAdditionalCode();
290+
291+
if (success)
292+
{
293+
//on success
294+
notification.Messages.Add(new EventMessage("Save Successful",
295+
"The content was saved successfully",
296+
EventMessageType.Success));
297+
}
298+
else
299+
{
300+
//on error
301+
notification.Messages.Add(new EventMessage("An Error occoured",
302+
"Detail about the error",
303+
EventMessageType.Error));
304+
}
305+
}
306+
```
307+
278308
## Samples
279309

280310
Below you can find some articles with some examples using Notifications.

0 commit comments

Comments
 (0)