I whipped up quick plugin to automatically show content fields as WYSIWYG. This will survive through updates.
Simply php artisan create:plugin Flynsarmy.WYSIWYGContent
and in the /plugins/flynsarmy/wysiwygcontent/Plugin.php file drop
public function boot()
{
Event::listen('backend.form.extendFields', function($form) {
// Only apply changes to Cms\Classes\Content form
if ( empty($form->config->model) ||
!is_object($form->config->model) ||
get_class($form->config->model) != 'Cms\Classes\Content' )
return;
foreach ($form->allFields as $field )
{
// Only apply changes to codeeditor fields
if ( empty($field->config['type']) || $field->config['type'] != 'codeeditor' )
continue;
$field->config['type'] = $field->config['widget'] = 'ShahiemSeymor\Ckeditor\FormWidgets\Wysiwyg';
// $field->config['type'] = $field->config['widget'] = 'Eein\Wysiwyg\FormWidgets\Trumbowyg';
}
});
}
Last updated
I dropped it, but I have an error:
We're sorry, but an unhandled error occurred. Please see the details below. Class 'Flynsarmy\WYSIWYGContent\Event' not found /.../plugins/flynsarmy/wysiwygcontent/Plugin.php line 29 Type Undefined Exception Symfony\Component\Debug\Exception\FatalErrorException public function boot() {
Event::listen('backend.form.extendFields', function($form) {
// Only apply changes to Cms\Classes\Content form
if ( empty($form->config->model) || !is_object($form->config->model) || get_class($form->config->model) != 'Cms\Classes\Content' )
return;
foreach ($form->allFields as $field )
{
Stack trace
Called Code Document Line
1 Illuminate\Exception\Handler->handleShutdown()
what should I do? thanks
Last updated
First of all thanks for sharing the code @Flynsarmy! Have created a plugin that does something similare, but in a new view and not in the normal content view. This is much better! Could be nice if there could be crated some type of page showing all the events you can hook into. This will make it allot easier to get an overview of what happens when.
Reagarding your issue @websac1915, I think your problem is that you havent added the correct Event class in your use definition at the top of the file. Try adding ´use Event;´ and see if it helps :)
kasper is right. Add use Event;
at the top. My bad.
Kasper, you can get a list of supported events by cding into october's root directory and typing find . -name "*.php" -exec grep -Hn "Event::fire" {} \;
but I agree, a docs page would be much nicer.
Last updated
1-7 of 7