我陷入了一点发展烦恼。我创建了一个扩展Sitecore创作界面的应用程序。 在Sitecore中创建新内容项之前,应用程序会查询某些内部服务并向内容作者提出一些其他问题。 我已经在(Sitecore.Shell.Applications.Templates.CreateTemplate.CreateTemplateForm)上建模了应用程序。
我遇到的问题是,一旦创建了一个项目,我的WizardForm就会被重新加载以加载新创建的项目。 我想要的是向导进入“最终”页面并在关闭模态对话框后重新加载主UI。 究竟新的OOTB模板向导如何工作。我知道如果我评论我的项目创建代码,UI就会按预期运行。 看起来像项目的创建会在UI响应的后台生成一些事件,并使用新创建的项目重新加载我的模态对话框。 (我尝试了以下解决方案http://sdn.sitecore.net/Forum/ShowPost.aspx?postid=29092,http://sdn.sitecore.net/Forum/ShowPost.aspx?postid=29968,但这似乎并没有为我解决这个问题。)
原始代码似乎禁用了这样的事件:
this.CreateTemplatePicker.DisableEvents();
TemplateItem templateItem = Client.ContentDatabase.Templates.CreateTemplate(this.TemplateName.Value, selectionItem);
this.CreateTemplatePicker.EnableEvents();
我尝试了以下内容:
Client.Site.Notifications.Disabled = true;
var item = container.Add(ItemUtil.ProposeValidItemName(this.Title.Value), Settings.ProductImageTemplateID);
Client.Site.Notifications.Disabled = false;
AND OLSO
Item item;
using (new EventDisabler())
{
item = container.Add(ItemUtil.ProposeValidItemName(this.Title.Value), Settings.ProductImageTemplateID);
}
所有结果都相同。一到达创建项目的页面,就会重新加载向导模式对话框。 使用fiddler我可以看到重新加载窗口的命令被发送到客户端。我只是想弄清楚如何告诉Sitecore UI忽略事件或者首先防止事件生成。发送到下面的UI的第一个命令告诉页面加载内容编辑器,这正是我试图阻止的事情。
{"commands":[
{"command":"SetLocation","value":"/sitecore/shell/sitecore/content/Applications/Content%20Editor.aspx?fo=%7b186F686E-A8FF-4303-B59F-4D284A5A0196%7d&db=master&id=%7B186F686E-A8FF-4303-B59F-4D284A5A0196%7D&la=en&vs=1"},
{"command":"SetDialogValue","value":"{186F686E-A8FF-4303-B59F-4D284A5A0196}"},
{"command":"SetStyle","value":"none","id":"Constraints","name":"display"},
{"command":"SetStyle","value":"","id":"LastPage","name":"display"},
{"command":"SetAttribute","value":true,"id":"NextButton","name":"disabled"},
{"command":"SetOuterHtml","value":"<button id=\"CancelButton\" class=\"scButton\" TabIndex=\"0\" onclick=\"javascript:return scForm.postEvent(this,event)\" onkeydown=\"javascript:scForm.handleKey(this, event, null, '32')\">Finish</button>","id":"CancelButton"},
{"command":"Focus","value":"CancelButton","scrollintoview":"0"},{"command":"Eval","value":"scUpdateWizardControls();"},
{"command":"SetAttribute","value":true,"id":"BackButton","name":"disabled"},{"command":"Eval","value":"scAlignWizardButtons()"}
]}
关于我的Sitecore环境的一点信息:
Sitecore started
Sitecore.NET 7.0. (rev. 130810)
C:\Inetpub\wwwroot\sc71\Website\bin\Sitecore.Client.dll (Sitecore CMS, Sitecore Client Application, 7.0 rev. 130810)
C:\Inetpub\wwwroot\sc71\Website\bin\Sitecore.Kernel.dll (Sitecore CMS, Sitecore CMS Kernel Library, 7.0 rev. 130810)
C:\Inetpub\wwwroot\sc71\Website\bin\Sitecore.Nexus.dll (Sitecore.Nexus)
Operating system Microsoft Windows NT 6.2.9200.0
Microsoft.NET version 4.0.30319.18051
Process id: 8040
Windows identity used by the process: NT AUTHORITY\NETWORK SERVICE. Impersonation: False
Managed pipeline mode: Integrated
答案 0 :(得分:0)
最后问题只影响了可用于铲斗的物品。无需禁用事件或任何东西,这是一个红色的鲱鱼。但是,在我的情况下,我正在处理水桶和水桶物品,所以我需要修复它。
违规代码结束为Sitecore.Buckets.Commands.AddFromTemplateCommand()
。感谢Sitecore支持工程师深入了解这一点。建议的解决方法对我有用,如下所示。这已经报告给Sitecore开发团队,我想将在未来的Sitecore版本的某个阶段得到解决。当前(在撰写本文时)版本Sitecore.NET 7.0. (rev. 130810)
受到影响。
您需要用自己的实现替换现有的实现(请参阅下面的代码)。要替换现有实现,请在/App_Config/Includes/Sitecore.Buckets.config
覆盖以下配置/sitecore/databases/database[@id="master"]
文件。我最终创建了一个看起来像这样的配置补丁文件。
配置:
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<databases>
<database id="master" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
<Engines.DataEngine.Commands.AddFromTemplatePrototype>
<obj patch:instead="obj[@type='Sitecore.Buckets.Commands.AddFromTemplateCommand, Sitecore.Buckets']"
type="Sitecore.Support.Buckets.Commands.AddFromTemplateCommand, MyAssembly"/>
</Engines.DataEngine.Commands.AddFromTemplatePrototype>
</database>
</databases>
</sitecore>
</configuration>
代码:
using Sitecore.Data.Items;
using Sitecore.Text;
using Sitecore.Web.UI.Sheer;
using System;
using System.Web;
namespace Sitecore.Support.Buckets.Commands
{
public class AddFromTemplateCommand : Sitecore.Buckets.Commands.AddFromTemplateCommand
{
protected override Sitecore.Data.Engines.DataCommands.AddFromTemplateCommand CreateInstance()
{
return new AddFromTemplateCommand();
}
protected override void SetLocation(Data.Items.Item item)
{
if ((HttpContext.Current != null) && (Context.ClientPage != null))
{
// This condition is set to go around an issue when a bucket item is created from within a custom wizard app.
// Replace the specified path with your own one.
if (Sitecore.Context.RawUrl != null && !Sitecore.Context.RawUrl.Contains("/sitecore/shell/Applications/Issues/Create Product Bucket.aspx"))
{
UrlString str = new UrlString(Sitecore.Buckets.Util.Constants.ContentEditorRawUrlAddress);
str.Add(Sitecore.Buckets.Util.Constants.OpenItemEditorQueryStringKeyName, item.ID.ToString());
item.Uri.AddToUrlString(str);
UIUtil.AddContentDatabaseParameter(str);
SheerResponse.SetLocation(str.ToString());
}
}
}
}
}