Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.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
C# Sitecore富文本编辑器自定义链接插入_C#_Asp.net_Sitecore - Fatal编程技术网

C# Sitecore富文本编辑器自定义链接插入

C# Sitecore富文本编辑器自定义链接插入,c#,asp.net,sitecore,C#,Asp.net,Sitecore,当用户使用RTE上的“插入链接”功能创建故事时,我们会得到类似于… 任何帮助都将不胜感激。谢谢最简单的方法是键入所需的链接文本,然后在单击“插入链接”之前选择此链接-这样,您的超链接将包含您输入的任何内容的文本,而不是默认的项目名称 如果要修改Sitecore在RTE字段中呈现链接的方式,则需要修改管道-如果在web.config中搜索此管道,您将在此处看到不同的类。使用可以反编译Sitecore源代码,以了解其工作原理。然后,您可以创建自己的renderField管道处理程序来更改链接呈现行

当用户使用RTE上的“插入链接”功能创建故事时,我们会得到类似于…


任何帮助都将不胜感激。谢谢

最简单的方法是键入所需的链接文本,然后在单击“插入链接”之前选择此链接-这样,您的超链接将包含您输入的任何内容的文本,而不是默认的项目名称


如果要修改Sitecore在RTE字段中呈现链接的方式,则需要修改
管道-如果在web.config中搜索此管道,您将在此处看到不同的类。使用可以反编译Sitecore源代码,以了解其工作原理。然后,您可以创建自己的renderField管道处理程序来更改链接呈现行为,然后在web.config中引用这个新类。

首先,您需要使用Reflector或DotPeek查看这个类:Sitecore.Shell.Controls.RichTextEditor.InsertLink.InsertLinkForm,并使用您自己的类修改它。 您只需修改此方法,我已测试并运行良好:

   protected override void OnOK(object sender, EventArgs args)
{
  Assert.ArgumentNotNull(sender, "sender");
  Assert.ArgumentNotNull((object) args, "args");
  string displayName;
  string text;
  if (this.Tabs.Active == 0 || this.Tabs.Active == 2)
  {
    Item selectionItem = this.InternalLinkTreeview.GetSelectionItem();
    if (selectionItem == null)
    {
      SheerResponse.Alert("Select an item.", new string[0]);
      return;
    }
    else
    {
      displayName = selectionItem["Headline"];
      if (selectionItem.Paths.IsMediaItem)
        text = CustomInsertLinkForm.GetMediaUrl(selectionItem);
      else if (!selectionItem.Paths.IsContentItem)
      {
        SheerResponse.Alert("Select either a content item or a media item.", new string[0]);
        return;
      }
      else
      {
        LinkUrlOptions options = new LinkUrlOptions();
        text = LinkManager.GetDynamicUrl(selectionItem, options);

      }
    }
  }
  else
  {
    MediaItem mediaItem = (MediaItem) this.MediaTreeview.GetSelectionItem();
    if (mediaItem == null)
    {
      SheerResponse.Alert("Select a media item.", new string[0]);
      return;
    }
    else
    {
      displayName = mediaItem.DisplayName;
      text = CustomInsertLinkForm.GetMediaUrl((Item) mediaItem);
    }
  }
  if (this.Mode == "webedit")
  {
    SheerResponse.SetDialogValue(StringUtil.EscapeJavascriptString(text));
    base.OnOK(sender, args);
  }
  else
    SheerResponse.Eval("scClose(" + StringUtil.EscapeJavascriptString(text) + "," + StringUtil.EscapeJavascriptString(displayName) + ")");
}
修改此类后,需要修改下一个文件: \sitecore\shell\Controls\Rich Text Editor\InsertLink\InsertLink.xml,您需要在其中更改代码节

<CodeBeside Type="Sitecore.Shell.Controls.RichTextEditor.InsertLink.InsertLinkForm,Sitecore.Client"/>

比如:

<CodeBeside Type="YourNameSpace.YourInsertLinkForm,YourAssembly"/>


非常感谢Sitecore攀登者!你是个救生员!:)再次感谢。也谢谢你。。女士。非常感谢,谢谢
<CodeBeside Type="YourNameSpace.YourInsertLinkForm,YourAssembly"/>