Change Markdown to Wysiwyg editor in RainLab.Blog

  1. Home
  2. Blog
  3. October CMS
  4. Change Markdown to Wysiwyg editor in RainLab.Blog

To change the Markdown editor to Wysiwyg in Rainlab.Blog, you need to add the following code to your plugin in Plugin.php:

public function extendRainlabBlog(){
    Event::listen('backend.form.extendFields', function($widget) {
        // Extend only the Posts controller or Post model
        if (!$widget.getController() instanceof \RainLab\Blog\Controllers\Posts ||
            !$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',
                'stretch' => 'true'
            ]
        ]);
    });
}

And then call the method in boot():

public function boot(){
    $this->extendRainlabBlog();
}
Wave