Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

HTMLEditorConfig custom config does not load editor.css from the theme


Go to End


2 Posts   706 Views

Avatar
Praveen

Community Member, 49 Posts

5 February 2015 at 9:17pm

Edited: 05/02/2015 9:28pm

Hi all,
First to note that Silverstripe Recipes seems not updated with any code except CustomConfigHTMLEditorField. The is outdated and does not support the silverstripe 3.1. I tried to customize and could not do so. I need to stop after checking the script that needs replace behaviour.register method in old with entwine method.
CustomConfigHtmlEditorField

Has I need only the replacement of content editor I created newcms configuration and set the following

public function getCMSFields() {
		$fields = parent::getCMSFields();	
		$fields->removeFieldFromTab('Root.Main', 'Content');
		HtmlEditorConfig::set_active('newcms');
		$htmlEditorConfig = HtmlEditorConfig::get('newcms');;
		$fields->insertAfter(new HtmlEditorField('Content', _t('SiteTree.HTMLEDITORTITLE', "Content", 'HTML editor title')),'Description');

		return $fields;
}

Now this shows editor without the editor.css styles .

Avatar
Praveen

Community Member, 49 Posts

5 February 2015 at 9:53pm

Edited: 05/02/2015 9:53pm

I have to add this to CMSFields to set the theme css file.

		$htmlEditorConfig = HtmlEditorConfig::get('newcss');	

		$cssFiles = array();
		$cssFiles[] = FRAMEWORK_ADMIN_DIR . '/css/editor.css';
		if(class_exists('SiteConfig') && ($config = SiteConfig::current_site_config()) && $config->Theme) {
			$theme = $config->Theme;
		} elseif(Config::inst()->get('SSViewer', 'theme')) {
			$theme = Config::inst()->get('SSViewer', 'theme');
		} else {
			$theme = false;
		}
		
		if($theme) $cssFiles[] = THEMES_DIR . "/{$theme}/css/editor.css";
		$htmlEditorConfig->setOption('content_css', implode(',', $cssFiles));

All because of Config::inst()->get('SSViewer', 'theme_enabled')
Where do I enable theme or disable it?