novius/laravel-backpack-visualcomposer
Composer 安装命令:
composer require novius/laravel-backpack-visualcomposer
包简介
This packages provides an interface to manage page content easily
README 文档
README
Improve the way you edit pages.
Installation
composer require novius/laravel-backpack-visualcomposer
Then add this to config/app.php:
Novius\Backpack\VisualComposer\VisualComposerServiceProvider::class,
Finally, run:
php artisan migrate
Use
In the model:
use \Novius\Backpack\VisualComposer\Traits\VisualComposer;
In the crud controller:
public function setup($template_name = false) { parent::setup($template_name); $this->crud->addField([ 'name' => 'visualcomposer_main', 'label' => 'Visual Composer', 'type' => 'view', 'view' => 'visualcomposer::visualcomposer', // (optionnal) Only those template will be available 'templates' => [ MyNewRowTemplate::class, ], // (optionnal) Pre-fill the visualcomposer with rows on new models 'default' => [ ['template' => MyNewRowTemplate::class], ], 'wrapperAttributes' => [ 'class' => 'form-group col-md-12', ], ]); } public function store(PageRequest $request) { $r = parent::store($request); $this->crud->entry->visualcomposer_main = $request->visualcomposer_main; return $r; } public function update(PageRequest $request) { $r = parent::update($request); $this->crud->entry->visualcomposer_main = $request->visualcomposer_main; return $r; }
In the model view:
@foreach($page->visualcomposer_main as $row) {!! $row->template::renderFront($row) !!} @endforeach
Create new row templates
Make a class and a folder for the views:
cd vendor/novius/laravel-backpack-visualcomposer class=MyNewRowTemplate touch src/app/Templates/$class.php mkdir src/resources/views/vendor/visualcomposer/$class touch src/resources/views/vendor/visualcomposer/$class/crud.blade.php touch src/resources/views/vendor/visualcomposer/$class/front.blade.php
In MyNewRowTemplate.php:
<?php namespace Novius\Backpack\VisualComposer\Templates; class MyNewRowTemplate extends RowTemplateAbstract { static public $name = 'my-new-row-template'; }
In crud.blade.php:
<div class="row-template vc-my-new-row-template"> <input type="hidden" class="content"> <textarea class="some_field" placeholder="{{ trans('visualcomposer::my-new-row-template.crud.some_field') }}"></textarea> </div> @push('crud_fields_scripts') <script> window['vc_boot', {!!json_encode($template)!!}] = function ($row, content) { var $hiddenInput = $(".content[type=hidden]", $row); var fields = [ 'some_field', ]; // Setup update routine var update = function () { var contents = []; fields.map(function (item) { contents.push($('.'+item, $row).val()); }); $hiddenInput.val( JSON.stringify(contents) ); }; // Parse and fill fields from json passed in params fields.map(function (item, index) { try { $('.'+item, $row).val(JSON.parse(content)[index]); } catch(e) { console.log('Empty or invalid json:', content); } }); // Update hidden field on change $row.on( 'change blur keyup', 'input, textarea, select', update ); // Initialize hidden form input in case we submit with no change update(); } </script> @endpush
In resources/lang/vendor/visualcomposer/en/templates.php, add:
<?php ... 'my-new-row-template' => [ 'name' => 'My new row template', 'crud' => [ 'some_field' => 'Some field for you to write something in', ], ],
Edit default config and templates
Run:
php artisan vendor:publish --provider="Novius\Backpack\VisualComposer\VisualComposerServiceProvider"
...it will output the list of copied files than can now be overwritten, including the config, the backpack field type, the language files and 11 built-in templates:
- Article, an wysiwyg and inputs for the title, subtitle, date, author, CTA button and user-customizable colors
- BackgroundImageAndText, an uploadable picture with a caption and wysiwyg description
- ImageInBase64, a picture stored as base64 instead of file upload
- ImageInContainer, an uploadable picture, and that’s it
- LeftImageRightText, a picture and some text fields on two columns
- LeftTextRightImage, some text fields and a picture on two columns
- LeftTextRightQuote, some text fields and customizable background color, on two columns
- Minimal, an empty template with the minimum code for it to work
- Slideshow, a slider of unlimited pictures and their captions
- ThreecolumnsImageTextCta, three columns with a picture, a title, a wysiwyg and a CTA button on each of them
- TwoColumnsImageTextCta, the same as above, but on two columns instead of three
Check out how they are made, so you can customize them and build your own.
novius/laravel-backpack-visualcomposer 适用场景与选型建议
novius/laravel-backpack-visualcomposer 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 3.45k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2018 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「crud」 「laravel」 「backpack」 「Novius」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 novius/laravel-backpack-visualcomposer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 novius/laravel-backpack-visualcomposer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 novius/laravel-backpack-visualcomposer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Gii Generator for double model generation
Extended summernote fields for laravel backpack
A PSR-7 compatible library for making CRUD API endpoints
Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.
Collection of tools to use the full power of the Enyalius framework
Use a translation namespace vor mutliple translation files.
统计信息
- 总下载量: 3.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: AGPL-3.0
- 更新时间: 2018-05-17