承接 grrr-amsterdam/oc-flexiblecontent-plugin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

统计信息

  • 总下载量: 2.01k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固