As a follow-up and as @mats found out, there is no way to have multiple HTMLEditorConfig's in SS 3.x out-of-the-box (As at March '14). Also, we shouldn't have to extend HTMLEditorField or HTMLEditorConfig to achieve this, so a core-patch will be required.
I needed some functionality almost identical to @matt and after a chat with Hamish, I came up with the following:
https://github.com/phptek/silverstripe-framework/tree/issue/multi-editor
- Multiple HTMLConfig's defined in _config.php = check.
- No additional fields = check.
- Tested: Only FF and Chrome on OS X.
- To add own config:
1). Adapt/create your own config in your module's or mysite's _config.php file.
2). Apply the patch from the repo above
3). Add an extra boolean param to your HtmlEditorField construct call e.g.
HtmlEditorConfig::set_active('my-basic-config');
new HtmlEditorField('MyField', 'My label', 3, 20, true);
4). Voila.
Caveats:
1). While this framework patch does work as far as switching between PageTypes with differing HTMLEditorConfig's set goes, there is a small JS glitch when swapping between them. If you switch from a Page with a custom config, back to a Page using the default config (This on a CWP SS 3.1 site) you'll notice that TinyMCE's default dropdown templates show for the <paragraph> and <heading> dropdowns. Simply reloading the page, "fixes" this.
2). This is untested in anything but Firefox and Chrome on OS X
I'm guessing some sort of editor JS redraw needs to be called, but not sure at this point what or where as yet.
Cheers
Russ
Posted to: HTMLEditorConfig - per Editor configuration - question from a humble n00b. | Show Thread | Post Reply