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

[solved] HTML Editor Configuration doesn't seem to work for me


Go to End


7 Posts   4030 Views

Avatar
bummzack

Community Member, 904 Posts

5 March 2010 at 3:53am

Edited: 05/03/2010 4:13am

Hello all

I'm creating a website where I'd prefer to have different WYSIWYG-Editor configurations for different user-groups. Apparently, the CMS already supports that, by allowing the admin to specify a "HTML Editor Configuration" in the "Security" > "Permissions" tab.

The CMS sees my configurations and also displays them in the dropdown. Everything seems to be saved just fine, but the CMS doesn't apply the settings. It always uses the default configuration.
Is there something I have to do myself here? Get the current user-group and apply it's editor config?

Any insight would be appreciated. Thanks

Avatar
bummzack

Community Member, 904 Posts

5 March 2010 at 4:12am

Figured it out.
Member->getHtmlEditorConfigForCMS() looks up the editor config to use.
It selects the best editor config based on priority.. so if you don't set a priority for your config, you will always end up with the default config.

The following solved the problem (default priority is 0):

HtmlEditorConfig::get('customConfig')->setOption('priority', 1);

Avatar
klikhier

Community Member, 150 Posts

6 May 2010 at 12:23am

Banal,

Could you explain how you managed to get the result of your first post in this thread. How did you create a custom HTML Editor Configuration and where did you put it?

Thanks!

Avatar
bummzack

Community Member, 904 Posts

6 May 2010 at 7:00am

Sure. A good place to define these configurations is in _config.php. Here's an example:

// NORMAL CONFIG
HtmlEditorConfig::get('cms')->disablePlugins('table', 'contextmenu');
HtmlEditorConfig::get('cms')->setButtonsForLine(1, 
	'bold','separator','pastetext','pasteword','separator','undo','redo','separator',
	'sslink','unlink','separator','bullist','numlist','charmap'
);
HtmlEditorConfig::get('cms')->setButtonsForLine(2);
HtmlEditorConfig::get('cms')->setButtonsForLine(3);

// ADMIN CONFIG
// create a new config named "admin"
$cfg = HtmlEditorConfig::get('admin');

// set the name for the config dropdown
$cfg->setOption('friendly_name', 'Administrators');

// set the config priority (must be bigger than 0)
$cfg->setOption('priority', 1);

// enable some of the required plugins for silverstripe
// @see /cms/_config.php for the default config!
$cfg->enablePlugins('media', '../../tinymce_ssbuttons', 'fullscreen');

// customize your buttons here.. similar to example above?

After doing so, you should be able to select the config for each Member-Group (in the Permissions tab).
I don't know, if this is all the same in 2.4 though. Didn't try it yet. Also have a look at /cms/_config.php and the HtmlEditorConfig class to get some pointers how this all works.

Avatar
klikhier

Community Member, 150 Posts

6 May 2010 at 8:35pm

Many thanks!

I ended up with just overwriting the existing HTMLEditorConfig for a most simple WYSIWYG editor.

// Set custom TinyMCE configuration
HtmlEditorConfig::get('cms')->setOption('theme_advanced_blockformats','p,h1');
HtmlEditorConfig::get('cms')->setButtonsForLine(1,'undo, redo, separator, cut, copy, pastetext, separator, ssimage, sslink, unlink, separator, fullscreen, advcode, formatselect');
HtmlEditorConfig::get('cms')->setButtonsForLine(2);
HtmlEditorConfig::get('cms')->setButtonsForLine(3);

Avatar
forester

Community Member, 4 Posts

9 November 2010 at 12:29am

Hi all,

I've just the same problem, but my solution doesn't change anything....

I just want to remove some buttons of the tinyMCE:

I've tried:
$cfg = HtmlEditorConfig::get('cms');
$cfg->setOption('priority',1);
$cfg->setButtonsForLine(1,'bold','underline','strikethrough','separator','justifyleft','justifycenter','justifyright','justifyfull','formatselect','separator','bullist','numlist','outdent','indent','blockquote','hr','charmap');
$cfg->setButtonsForLine(2,array('undo','redo','separator','cut','copy','paste','pastetext','pasteword','spellchecker','separator','advcode','search','replace','selectall','visualaid','separator','tablecontrols'));
$cfg->setButtonsForLine(3);

but there are still buttons in the third line and there is still the italic-button in the first

I would be very grateful for further assistance!

Avatar
forester

Community Member, 4 Posts

11 November 2010 at 2:10pm

Sry...i found my mistake!

Too much ' ... only one ' at the beginning and one at the end!

I'm so st***!