Is there a way to add a custome notification type to
ContentPublishingNotification
I am working on the following code:
public class ContentHandler : INotificationHandler
public ContentHandler(){}
public void Handle(ContentPublishingNotification notification)
{
//Here we need to get the meta tags from the page content
Boolean errorFound = false;
var page = notification.PublishedEntities;
foreach (var entity in page)
{
foreach(var p in entity.GetDirtyProperties())
{
string metaName = p.ToString().ToUpper();
if (metaName == "METANAME" || metaName == "METADESCRIPTION" || metaName == "METAKEYWORDS")
{
string proprtyName = p;
var propertyValue = entity.GetValue(proprtyName);
if (propertyValue == null)
{
errorFound = true;
}
}
}
if (errorFound)
{
notification.CancelOperation(new EventMessage("Content published, Please check SEO fields",
"One or more meta tags are missing.",
EventMessageType.Warning));
}
}
}
}}
Insted of using notification.CancelOperation I like to add my own notification type so that I can get the oroginal Page Piblished message and then run my meta tag message
But there dose not seem to be any documentation on how to do this in umbraco 10.
Extending ContentPublishingNotification
Hi,
Is there a way to add a custome notification type to ContentPublishingNotification
I am working on the following code:
public class ContentHandler : INotificationHandler
Insted of using notification.CancelOperation I like to add my own notification type so that I can get the oroginal Page Piblished message and then run my meta tag message
But there dose not seem to be any documentation on how to do this in umbraco 10.
Maybe you could append your own message as an additional message instead of canceling the operation?
var customMessage = new EventMessage("CustomMetaTagsValidation", "Oops! It looks like one or more meta tags are missing.", EventMessageType.Warning);
notification.Messages.Add(customMessage);
Thank you that work as I wanted.
is working on a reply...