Skip to content

Instantly share code, notes, and snippets.

@colymba
Created July 31, 2013 13:10
Show Gist options
  • Save colymba/6121825 to your computer and use it in GitHub Desktop.
Save colymba/6121825 to your computer and use it in GitHub Desktop.
Custom HtmlEditorConfig and TinyMCE multiple rendering
<?php
//skipping other config...
HtmlEditorConfig::get('mini')->setOptions(array(
'friendly_name' => 'Mini editor',
'priority' => '10',
'valid_elements' => "@[id|class|style|title],a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title"
. "|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],"
. "-ul[class],-li[class],br,"
. "-sub[class],-sup[class],"
. "-span[class|align|style],"
. "@[id,style,class]"
));
HtmlEditorConfig::get('mini')->setButtonsForLine(1, array('bold','italic','underline','strikethrough','separator','sslink', 'unlink','separator','justifyleft','justifycenter','justifyright','justifyfull','separator','bullist','numlist','separator','charmap','selectall','code','separator','undo','redo','pastetext'));
HtmlEditorConfig::get('mini')->setButtonsForLine(2, array());
HtmlEditorConfig::get('mini')->setButtonsForLine(3, array());
HtmlEditorConfig::get('mini')->disablePlugins('media','fullscreen','contextmenu','table','emotions','spellchecker');
HtmlEditorConfig::get('mini')->enablePlugins(array(
'ssbuttons' => sprintf('../../../%s/tinymce_ssbuttons/editor_plugin_src.js', THIRDPARTY_DIR)
));
<?php
class Presentation extends DataObject
{
private static $db = array(
'Title' => 'Text',
'Description' => 'HTMLText'
);
public function getCMSFields()
{
HtmlEditorConfig::set_active('mini');
$description = HTMLEditorField::create('Description', 'Short description');
$fields = new FieldList(
new TabSet(
'Root',
new Tab(
'Main',
$description
)
)
);
return $fields;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment