1

在 Sitecore 工作箱命令中,我们可以将“禁止评论”复选框设置为未选中,并且当执行该特定工作箱操作时,它会在弹出窗口中询问评论。我想让用户知道通过显示一些自定义文本来输入评论是强制性的。这可能吗?

4

1 回答 1

2

这是一篇关于在拒绝项目时强制发表评论的博客文章。您也可以轻松地将其用于您的目的:

Sitecore 工作流程 – 如果您拒绝某些内容,请发表评论!

如果您需要在用户尝试执行工作流命令之前显示消息,您可以覆盖 SitecoreWorkbox.xml控件并在其后面的代码中覆盖该Comment方法并更改"Enter a comment:"为您想要的任何内容。原始方法代码为:

public void Comment(ClientPipelineArgs args)
{
  Assert.ArgumentNotNull((object) args, "args");
  if (!args.IsPostBack)
  {
    Context.ClientPage.ClientResponse.Input("Enter a comment:", string.Empty);
    args.WaitForPostBack();
  }
  else if (args.Result.Length > 2000)
  {
    Context.ClientPage.ClientResponse.ShowError(new Exception(string.Format("The comment is too long.\n\nYou have entered {0} characters.\nA comment cannot contain more than 2000 characters.", (object) args.Result.Length)));
    Context.ClientPage.ClientResponse.Input("Enter a comment:", string.Empty);
    args.WaitForPostBack();
  }
  else
  {
    if (args.Result == null || !(args.Result != "null") || !(args.Result != "undefined"))
      return;
    IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;
    if (workflowProvider == null)
      return;
    IWorkflow workflow = workflowProvider.GetWorkflow(Context.ClientPage.ServerProperties["workflowid"] as string);
    if (workflow == null)
      return;
    Item obj = Context.ContentDatabase.Items[(Context.ClientPage.ServerProperties["id"] ?? (object) string.Empty).ToString(), Language.Parse(Context.ClientPage.ServerProperties["language"] as string), Sitecore.Data.Version.Parse(Context.ClientPage.ServerProperties["version"] as string)];
    if (obj == null)
      return;
    try
    {
      workflow.Execute(Context.ClientPage.ServerProperties["command"] as string, obj, args.Result, true, new object[0]);
    }
    catch (WorkflowStateMissingException ex)
    {
      SheerResponse.Alert("One or more items could not be processed because their workflow state does not specify the next step.", new string[0]);
    }
    UrlString urlString = new UrlString(WebUtil.GetRawUrl());
    urlString["reload"] = "1";
    Context.ClientPage.ClientResponse.SetLocation(urlString.ToString());
  }
}
于 2013-08-02T06:47:20.977 回答