Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何中止Sitecore中的saveui管道,然后重置值?_Sitecore_Sitecore6 - Fatal编程技术网

如何中止Sitecore中的saveui管道,然后重置值?

如何中止Sitecore中的saveui管道,然后重置值?,sitecore,sitecore6,Sitecore,Sitecore6,我正在尝试在Sitecore 6中实现一个saveui管道处理器。基本上,我已经创建了一个自定义处理器,根据用户在项目上可能更改的字段以及新数据是什么,向用户显示一条弹出消息。如果他们做了某些更改,则会显示一个弹出窗口,询问他们是否要继续。如果他们回答否,则管道中止。这一切都在起作用。然而,我注意到,当您中止管道时,Sitecore似乎所做的一切都不是保存。用户对内容项所做的所有更改仍在UI中。如果您离开Sitecore中的项目,它将提示您是否要保存更改。是否有某种方法可以让Sitecore U

我正在尝试在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();
    }
  }
}

您可以使用以下代码重新加载内容树

String refresh = String.Format("item:refreshchildren(id={0})", Sitecore.Context.Item.Parent.ID);
Sitecore.Context.ClientPage.SendMessage(this, refresh);
或者就像科里发现的那样,如果你想推荐你要使用的物品

String refresh = String.Format("item:load(id={0})", myOriginalItem.ID);
Sitecore.Context.ClientPage.SendMessage(this, refresh);

有关更多详细信息,请参见此

我认为您可以在中止自定义保存处理程序以设置内容项的初始值后尝试重新加载当前内容项。不确定您是否仍然收到“警报消息”


看看类似的问题

我该把代码放在哪里?它会进入我的定制SaveUI处理器吗?我尝试在args.AbortPipeline()行之后添加它,但没有效果。它什么也没做。另外,刷新内容项是否仍会显示Sitecore警告消息,询问我是否要先保存更改?是的,它应该在那里显示,您可能不会得到代码调用提示,或者您可能能够处理它。值得一试。是的,我试过了,但没用。它实际上似乎没有做任何事情。Sitecore.Context等项是否为您返回guid?代码看起来不错,我已经看过NewsMover模块,它在对项目进行排序后重新加载内容树。Ok。我发现Sitecore.Context.Item引用的是Core数据库中的一个项目(可能是因为我从saveui处理器运行此代码)。我修复了这个问题,并且能够对其进行更改,以便它现在引用的是相关内容项的父项。从代码中我可以看出,它告诉Sitecore刷新内容树并刷新项目父项的子项。嗯,就是这样。它刷新左侧的内容树。但它对右边的内容编辑器没有任何影响。我想刷新右边的内容编辑器表单。