Hi
Sorry if I explain things in a long way, I want to be specific though...
I would like to have a set of TinyMCE fields, each with different options, modules and buttons for different field types. I think I almost have a way to get this but not quite. Here's what I have so far:
Silverstripe version 2.4.2
In the file: /mysite/_config.php
I have defined my own set of options, buttons and plugins for TinyMCE with a new name as below:
HtmlEditorConfig::get('reduced')->setOptions(array(
// My options...
);
HtmlEditorConfig::get('reduced')->disablePlugins('table', 'contextmenu');
HtmlEditorConfig::get('reduced')->enablePlugins('media', 'fullscreen');
HtmlEditorConfig::get('reduced')->enablePlugins(array('ssbuttons' => '../../../cms/javascript/tinymce_ssbuttons/editor_plugin_src.js'));
HtmlEditorConfig::get('reduced')->setButtonsForLine(1,
'bold','separator','pastetext','pasteword','separator','undo','redo','separator',
'sslink','unlink', 'anchor', 'separator','bullist','numlist','ssimage', 'ssflash', 'fullscreen'
);
HtmlEditorConfig::get('reduced')->setButtonsForLine(2);
HtmlEditorConfig::get('reduced')->setButtonsForLine(3);
this works fine and in my home page php file - mysite/code/HomePage.php
I have:
function getCMSFields() {
$fields = parent::getCMSFields();
HtmlEditorConfig::set_active('reduced');
$reducedEditor = new HtmlEditorField('reducedEditor','Reduced-Editor',1);
$fields->addFieldToTab('Root.Content.Main',$reducedEditor,'Content');
// rest of fields...
}
In another file I created so I could set the active WYSIWYG settings back to the original - mysite/code/OtherPage.php
I have:
function getCMSFields() {
$fields = parent::getCMSFields();
HtmlEditorConfig::set_active('cms');
return $fields;
}
Here's the unexpected bit...
regardless of which page type I am editing the first loaded WYSIWYG settings are used.
eg: If from editing the home page I go to another section of the admin, for example Security, then I go back to the Pages section (it loads the last page I was editing), the 'reduced' settings are used. But then they are also used for every HtmlEditorField on any page type.
Then, if from another page which uses OtherPage.php, I go to another admin section and then back to the pages section, the default 'cms' options are loaded. Yes then 'cms' settings are used accross all page types too.
I expected set_active to be able to set the TinyMCE settings on each page the way I have used it.
Has anyone come up with a good workaround? I'm sure I'm not the only person who would like to be able to do this.
I was wondering if I could rename the HtmlEditorField to something else eg: ReducedHtmlEditorField and set the options specific to that.
Then based on whether I use HtmlEditorField or ReducedHtmlEditorField the custom options would be used but I'm not sure how or if it would still have the same issues.
eg:
function getCMSFields() {
$fields = parent::getCMSFields();
$defaultEditor = new HtmlEditorField('defaultEditor','Reduced-Editor',1);
$fields->addFieldToTab('Root.Content.Main',$defaultEditor,'Content');
$reducedEditor = new ReducedHtmlEditorField('reducedEditor','Reduced-Editor',1);
$fields->addFieldToTab('Root.Content.Main',$reducedEditor,'Content');
// rest of fields...
}