Skip to content

helpfulrobot/nathancox-customhtmleditorfield

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SilverStripe 3 Custom HTMLEditorField

Overview

This module adds two features to HTMLEditorField in SilverStripe 3:

  1. it allows you to set a custom body class on each editor field (for styling the content differently)
  2. it allows you to assign different HTMLEditorConfigs to each HTMLEditorField (eg to have different toolbars)

Maintainer Contacts

Requirements

  • SilverStripe 3.0+

Installation Instructions

  1. Place the files in a directory called customhtmleditorfield in the root of your SilverStripe installation
  2. Visit yoursite.com/dev/build to rebuild the database

Documentation

GitHub Wiki

Example code:

<?php

// make a new TinyMCE config called "footer" by copying the default ("cms") config
$footerConfig = CustomHtmlEditorConfig::copy('footer', 'cms');
// remove the third row of the editor toolbar: no tables in the footer!
$footerConfig->setButtonsForLine(3, array());

// make an HtmlEditorField
$fields->addFieldToTab('Root.Footer', $footerField = new HtmlEditorField('FooterText', 'Footer'));

// assign the "footer" TinyMCE config to this field
$footerField->setEditorConfig('footer');

// set the editor's body class.  This will make it class="typography footer-content"
$footerField->setBodyClass('footer-content');

Known Issues

Issue Tracker

About

A couple of hacks to allow per-editor content styles and TinyMCE configurations in SilverStripe 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 70.6%
  • JavaScript 29.4%