Last active
October 15, 2018 16:55
-
-
Save vojtasvoboda/5b8f9491ea3151671fa9 to your computer and use it in GitHub Desktop.
RainLab.Blog editor type change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Acme\Site; | |
use Event; | |
use Illuminate\Support\Facades\App; | |
use System\Classes\PluginBase; | |
/** | |
* Site Plugin Information File | |
*/ | |
class Plugin extends PluginBase | |
{ | |
public function pluginDetails() | |
{ | |
return [ | |
'name' => 'My site plugin', | |
'description' => 'Site config and overrides', | |
'author' => 'Vojta Svoboda', | |
'icon' => 'icon-puzzle-piece' | |
]; | |
} | |
public function registerPageSnippets() | |
{ | |
return [ | |
// register RainLab.Blog components as RainLab.Page snippets | |
'RainLab\Blog\Components\Post' => 'blogPost', | |
'RainLab\Blog\Components\Posts' => 'blogPosts', | |
'RainLab\Blog\Components\Categories' => 'blogCategories' | |
]; | |
} | |
public function boot() | |
{ | |
// Extend backend fields | |
Event::listen('backend.form.extendFields', function($widget) { | |
// Only for the RainLab.Blog Posts controller | |
if (!$widget->getController() instanceof \RainLab\Blog\Controllers\Posts) | |
return; | |
// Only for the RainLab.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' | |
] | |
]); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment