udokmeci/yii2-kont-trevor
Composer 安装命令:
composer require udokmeci/yii2-kont-trevor
包简介
Yii2 Sir Trevor + Mustache Custom Block Generator
README 文档
README
yii2 optimized content builder upon Sir Trevor wysiwyg custom components with Mustache, jQuery Cropper and others.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist udokmeci/yii2-kont-trevor "*"
or add
"udokmeci/yii2-kont-trevor": "*"
to the require section of your composer.json file.
Configuration
Once the extension is installed, simply use it in your code by :
... 'components'=>[ ... 'kontTrevor' => [ 'class' => 'udokmeci\yii2kt\KontTrevor', 'on init'=> function($e){ $e->sender->addProviders(require_once Yii::getAlias('@vendor/udokmeci//yii2-kont-trevor/src/udokmeci/yii2kt/config/base-blocks.php')); } ], ...
Form
On editor depends on perminder-klair/yii2-sir-trevor-js however you can add you custom blocks. Also register CustomSirTrevorAsset to view.
<?php \udokmeci\yii2kt\assets\CustomSirTrevorAsset::register($this); ?> <?= $form->field($model, 'body')->widget(\kato\sirtrevorjs\SirTrevor::classname(),[ 'debug'=>true, 'imageUploadUrl'=>Url::to(['/site/st-upload']), 'blockTypes' => [ 'Imagetop','Redactor', "Headex", 'Imageleft', 'Twocolumns', 'Threecolumns','Imageright','Textblock','Hr'], ]); ?>
Rendering
Rendering basically depends on mustache.php same template from blocks will be used however creating other blocks are possible. TODO: Block Interface
$convertor = new \udokmeci\yii2kt\Parser(); echo $convertor->toHtml($this->body);
Block Templating
On base-blocks.php there are defined templates for example Imagetop
[
'title'=>"Image On Top",
'type'=>"Imagetop",
'image'=>'/img/sir-trevor/imageLeft.png',
'templateObject'=>[
'img_1'=>[
'url'=>'https://s3-eu-west-1.amazonaws.com/yukumvar/upload/0aNk9D.',
],
'h2_1'=>'Title Goes Here',
'subtext_1'=>'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.',
],
'template'=><<<MST
<div class="row">
<div class="col-md-12">
<h2 class="st-required header1" data-st-part="data" data-role="editable-subblock" data-key="h2_1" >{{h2_1}}</h2>
</div>
<div class="col-md-12">
<img class="img-responsive center-block" src="{{img_1.url}}" alt="{{h2_1}}" title="{{h2_1}}" data-width="{{img_1.width}}" data-height='{{img_1.height}}' width="{{img_1.width}}" height='{{img_1.height}}'data-id="{{img_1.id}}" data-st-part="data" data-role="editable-image" data-max-width="1076" data-key="img_1"/>
</div>
<div class="col-md-12">
<p class="st-required" data-st-part="data" data-role="editable-subblock" data-key="subtext_1" >{{{subtext_1}}}</p>
</div>
</div>
MST
],
####title
Anything to write on adding menu.
####type
type to pass sir-trevor. Did not checked why but ucfirst non spaced type can be found only.
####image Any image to show on adding menu. If image is not added it tries its best to generate images from html markup but sucks now.
####templateObject Dummy data to work as placeholder on added block.
####template A Mustache template rendered on JS or PHP. So one template is used to pass to editor and on render. The new block will render automatically. #####data-st-part="data" *Required to proccessed by plugin.
#####data-role="editable-subblock" Works as text holder. On h* tags it pastes only text content. On other block clears formatting and keeps bold and italic only. Appends HTML on pastes.
#####data-role="editable-image" Makes image placeholder and puts controllers above it. You can select upload image, crop it and replace by front end. ######image data src, width, height, id is recorded. if image has id when uploading it sends the old id, if you like to replace image. ######data-max-width="1076" Before uploading reduces if the witdh of image is higher than that width in pixel units. Global setting is 1200px
Images can be combined with other editable-subblock data for alt and title attributes for SEO purposes.
The Current Situation?
There are too many dependencies since I have not find any time to make them combined. It may be used in admin panels only for now but you can serve this one to logged in users as well. You can change classes to fit any other framework.
udokmeci/yii2-kont-trevor 适用场景与选型建议
udokmeci/yii2-kont-trevor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 253 次下载、GitHub Stars 达 17, 最近一次更新时间为 2016 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「yii2」 「Sir Trevor」 「content builder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 udokmeci/yii2-kont-trevor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 udokmeci/yii2-kont-trevor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 udokmeci/yii2-kont-trevor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Sir Trevor to HTML conversion helper for PHP
A custom URL rule class for Yii 2 which allows to create translated URL rules
Sir Trevor JS in Laravel project
A SimpleSAMLphp module adding support for the PAPI protocol.
Yii 2 Sir Trevor JS widget
A SimpleSAMLphp module for pre-installing an IdP.
统计信息
- 总下载量: 253
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-15