Opening Rich Text Editor in custom field of Sitecore Content Editor
我正在 Sitecore 中为内容编辑器实现一个自定义字段,我需要能够打开富文本编辑器并从那里获取数据。我不太确定该去哪里看,也不知道如何去做。
必须反编译 Sitecore.Kernel DLL 才能解决这个问题。
首先是从
中分离出一个调用
所以,就我的情况而言:
1 2 3 4 5 6 | switch (message.Name) { case"richtext:edit": Sitecore.Context.ClientPage.Start(this,"EditText"); break; } |
然后你需要在你的类中有一个与上面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | protected void EditText(ClientPipelineArgs args) { Assert.ArgumentNotNull(args,"args"); if (args.IsPostBack) { if (args.Result == null || args.Result =="undefined") return; var text = args.Result; if (text =="__#!$No value$!#__") text = string.Empty; Value = text; UpdateHtml(args); //Function that executes Javascript to update embedded rich text frame } else { var richTextEditorUrl = new RichTextEditorUrl { Conversion = RichTextEditorUrl.HtmlConversion.DoNotConvert, Disabled = Disabled, FieldID = FieldID, ID = ID, ItemID = ItemID, Language = ItemLanguage, Mode = string.Empty, Source = Source, Url ="/sitecore/shell/Controls/Rich Text Editor/EditorPage.aspx", Value = Value, Version = ItemVersion }; UrlString url = richTextEditorUrl.GetUrl(); handle = richTextEditorUrl.Handle; ID md5Hash = MainUtil.GetMD5Hash(Source + ItemLanguage); SheerResponse.Eval("scContent.editRichText("" + url +"", "" + md5Hash.ToShortID() +""," + StringUtil.EscapeJavascriptString(GetDeviceValue(CurrentDevice)) +")"); args.WaitForPostBack(); } |