我正在尝试在 Sitecore 6 中实现 saveui 管道处理器。基本上,我创建了一个自定义处理器,根据他们可能在项目上更改的字段以及新数据是什么,向用户显示弹出消息。如果他们进行了某些更改,则会向他们显示一个弹出窗口,询问他们是否要继续。如果他们回答“否”,则管道将中止。这一切都在起作用。但是我注意到,当您中止管道时,所有 Sitecore 似乎都不会保存。用户对内容项所做的所有更改仍然存在于 UI 中。如果您离开 Sitecore 中的项目,它会提示您是否要保存更改。有什么方法可以让 Sitecore UI 取消所有更改并将所有字段恢复为初始值?中止管道很好,因为我不想保存,但我也想在 UI 中取消保存。有谁知道如何做到这一点?
示例代码:
public class CustomSaveProcessor
{
public void Process(SaveArgs args)
{
Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
if(args.Items == null)
{ return; }
if(args.IsPostback)
{
if(args.Parameters["runContext"] == "firstQuestion")
{
if((args.Result == null) || (args.Result == "null") || (args.Result == "no") || (args.Result == "cancel"))
{
args.AbortPipeline();
//Should there be something here to tell the Sitecore UI to reset the values?
return;
}
else
{
//User has answered first question Yes
//This means they want to save the changes to the item
//We also want to ask a second question that effects other content items
SheerResponse.YesNoCancel("Do you want to also modify other items?", "300px", "200px");
args.Parameters["runContext"] = "secondQuestion";
args.WaitForPostBack();
}
}
else
{
if(args.Result == "yes")
{
//This is the answer to second question
//Custom code here to modify other content items
}
//We are completely done now.
return;
}
}
else
{
//Ask the user the first question
SheerResponse.YesNoCancel("Are you sure you want to proceed?", "300px", "200px");
args.Parameters["runContext"] = "firstQuestion";
args.WaitForPostback();
}
}
}