[![Total Downloads][ico-downloads]][link-downloads]
This package provides a visual editor field type for the Backpack for Laravel administration panel. The visual editor field allows admins to use a visual composer like editor in a field to create their own content.
Via Composer
composer require bedoz/visual-editor-for-backpack
Inside your custom CrudController:
$this->crud->addField([
'name' => 'editor',
'label' => "Visual Editor",
'type' => 'visual-editor',
'view_namespace' => 'visual-editor-for-backpack::fields',
]);
Notice the view_namespace
attribute - make sure that is exactly as above, to tell Backpack to load the field from this package, instead of assuming it's inside the Backpack\CRUD package.
If you need to add more custom fields to editor, you need to follow these steps.
- Create views
You need to create 2 files,backend.blade.php
andfrontend.blade.php
within a subfolder onviews/vendor/visual-editor-for-backpack/blocks
.
Example:views/vendor/visual-editor-for-backpack/blocks/newField/backend.blade.php
andviews/vendor/visual-editor-for-backpack/blocks/newField/frontend.blade.php
Thebackend.blade.php
have everything you need to manage admin input
Thefrontend.blade.php
have everything you need to show result on site - If you have some translations to load into your field create a file inside
resources/lang/vendor/visual-editor-for-backpack/LANG/blocks
with the name of the field likeresources/lang/vendor/visual-editor-for-backpack/LANG/blocks/newField.php
, remember to create a new file for every language you use - Create a new class with the name of you field in
app/Blocks
likeapp/Blocks/NewField.php
start with something like:Here you can use pushStyle and pushScripts to load your CSS and JS.<?php namespace app\Blocks; use Bedoz\VisualEditorForBackpack\Blocks\Block; class Newfield extends Block { public static $name = 'newField'; public static $label = 'New Field Label'; static public function pushStyle() { return ""; } static public function pushScripts() { return ""; } }
- Final you must add your class inside
visual-editor.php
config file like below:return [ 'blocks' => [ \Bedoz\VisualEditorForBackpack\Blocks\Slideshow::class, ++ \App\Blocks\Newfield::class, ], ];
Please see the changelog for more information on what has changed recently.
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email the author instead of using the issue tracker.
- Bedoz - creator of this package;
- All Contributors
MIT. Please see the license file for more information.