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 - per Editor configuration - question from a humble n00b.


Go to End


10 Posts   7390 Views

Avatar
Jimmis

Community Member, 4 Posts

12 January 2011 at 12:15pm

Hi there,

Just a quick question, any help would be greatly appreciated.

Is it possible to customize the TinyMCE editor on a per 'TinyMCE Editor Field' basis?

ie: I want 3 TinyMCE fields on a page, each one containing only certain buttons and allowed HTML tags etc.

Thanks in advance.
kind regards
James

Avatar
Willr

Forum Moderator, 5523 Posts

12 January 2011 at 8:20pm

You can set the htmleditorconfig values in the getCMSField. You can also have multiple htmleditor configs defined and swap between them when making your getCMSFields.

$fields->addFieldToTab('Root.Main', new HtmlEditorField('Field'));
HtmlEditorConfig::set_active('cms-small');
$fields....
HtmlEditorConfig::set_active('...');

Avatar
muskie9

Community Member, 24 Posts

12 July 2011 at 7:06am

Hi all,

Building off of this concept:

Would anything change with setting the config for a front end form?

I have created a new fieldset:

$fields = new FieldSet(
new TextField('Title', 'Product Name'),
new CurrencyField('Price', 'Price'),
new NumericField('TotalAvailable','Total Available'),
new ImageUploadField('MainImage', 'Main Image'),
new HTMLEditorField('Content', 'Product Description')
);

Would I still use something like HtmlEditorConfig::set_active('cms-small') after declaring the new fieldset?

Thanks,

Nic

Avatar
Myrdhin

Community Member, 70 Posts

15 September 2011 at 2:54am

Edited: 15/09/2011 2:55am

Hello Willr,

I can't make your code works :(

i tried this in my decorator object :

	public function updateCMSFields(FieldSet $fields) {
		// backup current HtmlEditorConfig identifier (is it usefull ?)
		$oldActiveConfig = HtmlEditorConfig::$current;

		$basicConfig = HtmlEditorConfig::get('basic');
		$basicConfig->setButtonsForLine(1, array('bold','italic','underline'));
		$basicConfig->setButtonsForLine(2, array());
		$basicConfig->setButtonsForLine(3, array());
		$basicConfig->setOptions( array(
			'friendly_name' =>'Basic HTML Editor'
		));

		HtmlEditorConfig::set_active('basic');
		$HtmlEditorField = new HtmlEditorField("Presentation", _t('Presentation.SINGULARNAME', 'Presentation') );
		// restore old current HtmlEditorConfig identifier (is it usefull ?)
		HtmlEditorConfig::set_active($oldActiveConfig);

		$fields->addFieldToTab("Root.Main", $HtmlEditorField);
	}

but all HtmlEditorFields in all Pages (in admin interface) are now 'basic'...

Avatar
Myrdhin

Community Member, 70 Posts

16 September 2011 at 8:23pm

Avatar
mightycoco

Community Member, 3 Posts

21 March 2012 at 6:04am

Thanks for the CustomConfigHtmlEditorField tip - that one is really a live-safer :)

Avatar
mats

Community Member, 5 Posts

13 August 2012 at 12:22am

Has anybody successfully done different editor configurations in one form with 3.0? Somehow it's always the last active configuration that gets used for all HtmlEditorFields on the page... I aim to have two fields allowing only bold and italic formatting plus one full-fledged editor field in my form. Whatever i do though, i end up with having one config or the other on all three fields. Is there some way to apply a configuration per editor instance?

Any help greatly appreciated,
mats

Avatar
muskie9

Community Member, 24 Posts

13 August 2012 at 2:37am

Here's a video tut by uncle cheese utilizing bootstrap forms with SS3. I think he goes through configuring the HTMLEditorFields:

http://www.leftandmain.com/silverstripe-screencasts/2012/07/03/bootstrap-forms-for-silverstripe-3/

Go to Top