有可能吗?我是管理员。我想在编辑者(或作者或有权访问的人)创建某些内容(例如在“新闻”文档类型中输入“新闻”)时通过电子邮件收到通知。如何?我使用Umbraco 7.5
您需要编码到Umbraco ContentService事件中。
以下内容将帮助您入门。每当发布项目时都会触发该事件。
尽管要小心,但要注意。如果有人发布父节点及其所有子节点,您可能会收到大量无用的电子邮件。
您还可以挂入其他事件,因此请参考https://our.umbraco.com/Documentation/Reference/Events/ContentService-Events-v7上的文档。
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
namespace My.Namespace
{
public class MyEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Published += ContentServicePublished;
}
private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args)
{
foreach (var node in args.PublishedEntities)
{
// Your code to send email here
}
}
}
}
您可以通过创建一些事件处理程序来编写自己的自定义代码,这是@wingyip的建议,或者您可以使用内置的Umbraco通知功能。
有关第二个内置选项,请在on this post处查看所有步骤。