我一直想要实现特定于站点的富文本css类,但是遇到了一个问题。我不能在这种环境中改变任何全球性的东西。 tutorials要求我更改EditorPage.aspx文件。我无法做到这一点。有没有其他方法为富文本编辑器设置特定于站点的css类?
我在Sitecore 7.5上。
谢谢!
答案 0 :(得分:3)
这与previous Stackoverflow question非常类似,我回答了多个RTE类样式,后面跟着blog post,其中包含有关在Sitecore富文本编辑器中加载特定于站点的CSS样式的详细信息。 / p>
创建一个继承自EditorConfiguration
的新Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration
类,并覆盖SetupStylesheets()
方法。然后根据HTML编辑器配置文件在“核心”数据库中注册新的配置类型,然后将模板中RTE字段的来源设置为您的富文本配置文件。
在SetupStylesheets()
方法中,您需要使用xpath查询来获取特定于站点的css文件列表:
protected override void SetupStylesheets()
{
string id = WebUtil.GetQueryString("id");
string query = "/*/content//*[@@id='" +id+ "']/ancestor::*[@@templateid='{root-guid}']//*[@@templateid='{style-folder-guid}']/*";
IList<Item> stylesheets = Sitecore.Context.ContentDatabase.SelectItems(query);
foreach (Item item in stylesheets)
{
this.Editor.CssFiles.Add(item["Stylesheet"]);
}
base.SetupStylesheets();
}