Technical notes about OctoberCMS a Laravel CMS. Notes are written by inetis team, a Swiss webagency

<- Back

Wysiwyg editor for RainLab Blog component

Posted on by

Default RainLab plugin use BlogMarkdown as editor. For non technician users, I prefer to use the regular editor.

How can it be changed?

The easy way

Edit the file /plugins/rainlab/blog/models/post/fields.yaml and change type:
RainLab\Blog\FormWidgets\BlogMarkdown to richeditor.

fields:
    content:
       tab: rainlab.blog::lang.post.tab_edit
               type: RainLab\Blog\FormWidgets\BlogMarkdown
               cssClass: field-slim blog-post-preview
               stretch: true
               mode: split</p>

The downside of this method is that you will lose your changes at the next update. You will have to reapply the fix.

With a "Small Extensions" plugin

This plugin offer many options. One of them is : Replace default Markdown editor with WYSIWIG richtext editor, change it's toolbar buttons.

https://octobercms.com/plugin/janvince-smallextensions

With a custom plugin

Create a plugin and add this boot() function

<?php namespace Inetis\Bootsettings;

use System\Classes\PluginBase;
use Event;

class Plugin extends PluginBase
{
     public function boot()
    {
        // Extend all backend form usage
        Event::listen('backend.form.extendFields', function($widget) {

            // Extend only the Blog\Posts controller
            if (!$widget->getController() instanceof \RainLab\Blog\Controllers\Posts)
                return;

            // Extend only Blog\Post model
            if (!$widget->model instanceof \RainLab\Blog\Models\Post)
                return;

            // Update content field
            $widget->addSecondaryTabFields([
                'content' => [
                    'tab' => 'rainlab.blog::lang.post.tab_edit',
                    'type' => 'richeditor',
                    'size' => 'huge'
                ]
            ]);
        });
    }

}

Thanks to https://github.com/vojtasvoboda

Source: https://github.com/rainlab/blog-plugin/issues/112