这是我尝试过的代码,相同的代码在项目保存事件中对我有用。
public void OnPublishEnd(object sender, EventArgs args)
{
SitecoreEventArgs eventArgs = args as SitecoreEventArgs;
Item item = eventArgs.Parameters[0] as Item;
}
“项目”返回空值。我应该在这里使用什么来从 eventargs 获取项目?
弄清楚了,
SitecoreEventArgs eventArgs = args as SitecoreEventArgs;
Item item = ((Sitecore.Publishing.Publisher)(eventArgs.Parameters[0])).Options.RootItem as Item;//eventArgs.Parameters[0] as Item;
Item existingItem = item.Database.GetItem(item.ID, item.Language, item.Version);
这行得通!