SilverStripe 3.2 HTMLEditorField使用HtmlEditorConfig自定义css样式
我已经在内容htmleditor字段之前添加了HtmlEditorConfig。问题是,我需要刷新或重新加载浏览器页面以查看我的自定义css设置 我的代码:SilverStripe 3.2 HTMLEditorField使用HtmlEditorConfig自定义css样式,css,field,silverstripe,Css,Field,Silverstripe,我已经在内容htmleditor字段之前添加了HtmlEditorConfig。问题是,我需要刷新或重新加载浏览器页面以查看我的自定义css设置 我的代码: HtmlEditorConfig::get('cms')->setOption('content_css', '/themes/simple/css/test'.$this->variable.'.css, /themes/simple/css/typography.css'); $fields->addFieldsToT
HtmlEditorConfig::get('cms')->setOption('content_css', '/themes/simple/css/test'.$this->variable.'.css, /themes/simple/css/typography.css');
$fields->addFieldsToTab("Root.Main", new HTMLEditorField('Content', 'Content'));
我的问题:当页面或数据对象加载时,是否可以自动刷新HTMLEditorField以使用HtmlEditorConfig设置?我不能在_config.php中使用它,因为我的自定义HtmlEditorConfig代码中有一个变量。我找到了解决方案!还有另一种方法可以使用一些自定义变量将HTMLEditorConfig配置为。在/mysite/_config.php中,无法使用HTMLEditorConfig添加变量。只有在刷新URL一次时,将HTMLEditorConfig包含到带有HTMLEditorField的Page类中才起作用 解决方案是使用LeftAndMain扩展扩展扩展LeftAndMain。这是我的解决方案代码: /mysite/_config.php
Object::add_extension("LeftAndMain", "HTMLEditorConfigSubsitesInit");
/mysite/code/htmleditorconfigsubsiteinit.php
class HTMLEditorConfigSubsitesInit extends LeftAndMainExtension
{
function init()
{
$SiteConfig=SiteConfig::get()->filter('SubsiteID', Subsite::currentSubsiteID() )->First();
$stripedMainFont = str_replace(" ", "-", $SiteConfig->MainFont );
HtmlEditorConfig::get('cms')->setOption('content_css', '/mysite/css/fonts_'.$stripedMainFont.'.css, /assets/Subsite'.Subsite::currentSubsiteID().'/_customstyles.css, /themes/'.$SiteConfig->Theme.'/css/typography.css');
}
}
对于HTMLEditor自定义来说,使用模块添加与子网站相关的CSS样式文件非常有用