WYSIWYG: Add custom buttons to load blocks?

edited January 2016 in Modules
Hi!
I would like to add a button to the WYSIWYG editor in the backend so that my clients can insert blocks without having to type the simplified markdown like {fuel_block('...')}. I am new to FUEL and I am learning very slowly, so would someone be willing to help me out by pointing me in the right direction? What would need to be done to (1) make a new button on the editor (2) when that button is clicked, load a window (like when you are adding tags/categories/etc.) with a list of all blocks and then (3) when a block is chosen, insert the markdown for that block by the cursor in the editor.

Thanks so much!
Z

Comments

  • edited 11:08AM
    Are you using the default markItUp! editor or CKEditor (which can be configured in the MY_fuel.php $config['text_editor'] value).
  • edited 11:08AM
    I'm using the CKeditor.
  • edited 11:08AM
    To create CKEditor plugins, you'll need to dig a little bit into the CKEditor documentation. The fuelimage and fuellink can be looked at as examples. Note that in the fuel/application/config/editors.php file it shows how they are both Added to the toolbar (FUELImage and FUELLink/FUELUnlink respectively) and they are also included as "extraPlugins". The code for fuelimage and fuellink plugins is in the fuel/modules/fuel/assets/js/editors/ckeditor/plugins folder:
    $config['ckeditor']['default'] = array( 'toolbar' => array( array('Bold', 'Italic', 'Strike'), array('Format'), array('FUELImage', 'HorizontalRule'), array('NumberedList', 'BulletedList'), array('FUELLink', 'FUELUnlink'), array('Undo', 'Redo', 'RemoveFormat'), array('PasteFromWord', 'PasteText'), array('Maximize'), ), 'contentsCss' => WEB_PATH.'assets/css/main.css', 'htmlEncodeOutput' => FALSE, 'entities' => FALSE, 'bodyClass' => 'ckeditor', /*'protectedSource' => array('/\{fuel_\w+\(.+\)\}/g', '/<\?[\s\S]*?\?>/g'), */ 'toolbarCanCollapse' => FALSE, 'extraPlugins' => 'fuellink,fuelimage', 'removePlugins' => 'link,image', 'allowedContent' => TRUE, );
    http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1
  • edited 11:08AM
    Awesome, thanks. I will update the thread if any issues arise!
Sign In or Register to comment.