Add more fonts to the Redactor-Plugin "font family"
This is a community-contributed tutorial. This tutorial is over a year old and may not apply to your version of Concrete CMS.
Aug 18, 2015
Note: This has been tested only in version 5.7.4.2 Also, this is for packages or packaged themes.
- Copy the
fontfamily.js
from/concrete/js/build/vendor/redactor/
to your package folder:/packages/package_handle/js/build/vendor/redactor/
- Rename the file to something unique like
allmyfonts.js
In the
allmyfonts.js
file , rename theRedactorPlugins
function fromfontfamily
toallmyfonts
://... (function($) { RedactorPlugins.allmyfonts = function() { return { //...
Still in the
allmyfonts.js
file, add your fonts to the arrayfonts
in theinit()
function://... init: function () { var fonts = [ 'Verdana', 'Helvetica', 'Georgia', 'Times New Roman', 'Monospace', 'Ubuntu', 'And So on' ]; var that = this; var dropdown = {}; //...
In the package controllers
on_start()
method, register theallmyfonts.js
file:public function on_start() { $pkg = $this; $al = Asset\AssetList::getInstance(); $al->register( 'javascript', 'allmyfonts', 'js/build/vendor/redactor/allmyfonts.js', array('position' => \Asset::ASSET_POSITION_FOOTER), $pkg ); $al->registerGroup('allmyfonts', array( array('javascript', 'allmyfonts'), )); $plugin = new Plugin(); $plugin->setKey('allmyfonts'); $plugin->setName('allmyfonts'); $plugin->requireAsset('allmyfonts'); \Core::make('editor')->getPluginManager()->register($plugin); }
Call (require) your
allmyfonts.js
in the single page controllerson_start()
method:public function on_start() { $this->requireAsset('javascript', 'allmyfonts'); // Important! Don't forget to call the `parent::on_start()` method at the end! parent::on_start(); }
On the single page, initialize the redactor:
$editor = Core::make('editor'); $editor->getPluginManager()->select('allmyfonts');
And call it in the DOM:
print $editor->outputStandardEditor('text_area_name_attribute', 'content');
Clear cache & Reinstall the package