【问题标题】:How to add custom fields into October CMS static pages plugin?如何在十月 CMS 静态页面插件中添加自定义字段?
【发布时间】:2016-04-14 14:28:51
【问题描述】:

我想在静态页面插件的菜单表单中添加自定义字段“缩略图”。

我已经将此字段添加到 project/plugins/rainlab/pages/classes/menuitem/fields.yaml 中

# ===================================
#  Field Definitions
# ===================================

fields:

    title:
        span: left
        label: rainlab.pages::lang.menuitem.title

    type:
        span: right
        label: rainlab.pages::lang.menuitem.type
        type: dropdown

    url:
        label: rainlab.pages::lang.menuitem.url

    reference:
        label: rainlab.pages::lang.menuitem.reference
        type: dropdown
        cssClass: input-sidebar-control

    thumbnail:
        label: Thumbnail
        mode: file
        cssClass: input-sidebar-control
        type: mediafinder

// another part of code is default

同样添加到project/plugins/rainlab/pages/classes/MenuItem.php

public $thumbnail;

public $fillable = [
    'title',
    'nesting',
    'type',
    'url',
    'code',
    'reference',
    'cmsPage',
    'replace',
    'viewBag',
    'thumbnail' // new field
];

但它不起作用。如何解决这个问题呢?谢谢。

【问题讨论】:

    标签: php laravel-5 laravel-5.1 octobercms


    【解决方案1】:

    对于简单类型的字段也需要修改js文件

    plugins/rainlab/pages/formwidgets/menuitems/assets/js/menu-items-editor.js
    

    在函数中

    MenuItemsEditor.prototype.applyMenuItem
    

    更改基本属性

    例子

    basicProperties = {
                'title': 1,
                'type': 1,
                'code': 1,
                'thumbnail': 1
            },
    

    但是对于文件它不起作用。

    【讨论】:

      【解决方案2】:

      我认为您必须扩展插件,文档中的更多信息:https://octobercms.com/docs/plugin/extending#extending-backend-form

      【讨论】:

        猜你喜欢
        • 2017-07-27
        • 2018-11-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-19
        • 2015-11-08
        相关资源
        最近更新 更多