grrr-amsterdam/oc-flexiblecontent-plugin
Composer 安装命令:
composer require grrr-amsterdam/oc-flexiblecontent-plugin
包简介
OctoberCMS Plugin for adding flexible content to models.
README 文档
README
Inspired by the the Advanced Custom Fields PRO plugin for Wordpress, this plugin allows you to create flexible content blocks for your OctoberCMS website. This plugin will take care of the editing part, and the rendering part.
This package also contains a flexible model object field 'fc-model-object' for searchable select (Select2) that allows you to select a model object and use it in your flexible content block, without having an eloquent relation to the model.
Installation
composer require grrramsterdam/flexiblecontent-plugin
Usage
You can add flexible content blocks by adding them to themes/your-theme/flexible-content/groups.yaml.
This is essentially the groups option a repeater field. Each group must specify a unique key and the definition supports the
following options. name, description, icon en fields.
Example:
text: name: Text description: A simple text block icon: icon-align-left fields: text: label: Text type: richeditor text_media: name: Text with media description: A text block with media icon: icon-align-left fields: text: label: Text type: richeditor media: label: Media type: mediafinder
Flexible model object field
With this field you can create a searchable model object field that can be used in your flexible content block. You can use this field to select a model object without having an eloquent relation to the model.
Usage
fields: model_object: label: Pick example type: fc-model-object model: Grrr\FlexibleContent\Models\ExampleModel nameFrom: title emptyOption: "Select an example item" # searchEndpoint: grrr/project-plugin/example-models/search-select-options
Asynchronous select options
By default an all() query will be done for the model to dynamically populate the select options.
But this can be a memory issue very quickly. You can specify a searchEndpoint option. This should
be a route to an OctoberCMS backend controller that returns a JSON response with the following
format:
{
"results": [
{
"id": 1,
"text": "Example item 1"
},
{
"id": 2,
"text": "Example item 2"
}
]
}
This packages provides a behaviour GrrrAmsterdam\FlexibleContent\Behaviors\HasSearchableSelectOptions
that you can use in a controller that also uses the FormController behaviour. Register it in a
controller like this:
// [plugin path]/controllers/Examples.php public $implement = [ 'Backend\Behaviors\FormController', 'GrrrAmsterdam\FlexibleContent\Behaviors\HasSearchableSelectOptions', ];
Be the default the search query will be done on the title attribute of the model. You can overwrite
the getSearchableSelectOptions() method on your controller to change this behaviour.
This behaviour will add a route to the controller with the following backend path:
{vendor}/{plugin}/{controller}/search-select-options. You can use this path as the searchEndpoint
option.
grrr-amsterdam/oc-flexiblecontent-plugin 适用场景与选型建议
grrr-amsterdam/oc-flexiblecontent-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.01k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 grrr-amsterdam/oc-flexiblecontent-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 grrr-amsterdam/oc-flexiblecontent-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-13