定制 heimrichhannot/contao-fieldpalette-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

heimrichhannot/contao-fieldpalette-bundle

Composer 安装命令:

composer require heimrichhannot/contao-fieldpalette-bundle

包简介

FieldPalette is a contao widget like MultiColumnWizard with its own database table.

README 文档

README

If you're in search of an multi column input field and the storage of values in another table isn't an explicit requirement, we recommend to use Multi Column Editor Bundle instead, as it has less possible side effects and is more often updated due it's higher usage.

FieldPalette is a contao widget similar to MultiColumnWizard. Unlike MultiColumnWizard, fields are stored flatly into tl_fieldpalette table and synced with its parent field.

The fieldpalette configuration is based on Contao's Data Container Arrays.

alt fieldpalette wizard FieldPalette Wizard - ListView

alt fieldpalette edit FieldPalette Wizard - Edit item

Technical instructions

Install

composer require heimrichhannot/contao-fieldpalette-bundle

You need to updated the contao database updated.

Getting started

FieldPalette comes with an custom input type fieldpalette. The configuration for this input type is done in the fieldpalette index of the field configuration array. You can customize your fieldpalette nearly as an "normal" dca configuration. When you finished setting up your fieldpalette input, you need to call the contao database tool to add the new fields to the table. See following example for a real world use case:

Default Setup (tl_fieldpalette table)

This example shows the setup of an fieldpalette field within tl_news by using it within an subpalette. That (shortend) example is available within the module Contao News Leisure Bundle.

# contao/dca/tl_news.php

$GLOBALS['TL_DCA']['tl_news']['fields']['venues'] = [
    'inputType' => 'fieldpalette',
    'foreignKey' => 'tl_fieldpalette.id',
    'relation' => ['type' => 'hasMany', 'load' => 'eager'],
    'sql' => "blob NULL",
    'fieldpalette' => [
        'config' => [
            'hidePublished' => false
        ],
        'list' => [
            'label' => [
                'fields' => ['venueName', 'venueStreet', 'venuePostal', 'venueCity'],
                'format' => '%s <span style="color:#b3b3b3;padding-left:3px">[%s, %s %s]</span>',
            ],
        ],
        'palettes' => [
            'default' => 'venueName,venueStreet,venuePostal,venueCity',
        ],
        'fields' => [
            'venueName' => [
                'label' => &$GLOBALS['TL_LANG']['tl_news']['venueName'],
                'exclude' => true,
                'search' => true,
                'inputType' => 'text',
                'eval' => ['maxlength' => 255, 'tl_class' => 'long'],
                'sql' => "varchar(255) NOT NULL default ''",
            ],
            'venueStreet' => [
                'label' => &$GLOBALS['TL_LANG']['tl_news']['venueStreet'],
                'exclude' => true,
                'search' => true,
                'inputType' => 'text',
                'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
                'sql' => "varchar(255) NOT NULL default ''",
            ],
            'venuePostal' => [
                'label' => &$GLOBALS['TL_LANG']['tl_news']['venuePostal'],
                'exclude' => true,
                'search' => true,
                'inputType' => 'text',
                'eval' => ['maxlength' => 32, 'tl_class' => 'w50'],
                'sql' => "varchar(32) NOT NULL default ''",
            ],
            'venueCity' => [
                'label' => &$GLOBALS['TL_LANG']['tl_news']['venueCity'],
                'exclude' => true,
                'filter' => true,
                'search' => true,
                'sorting' => true,
                'inputType' => 'text',
                'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
                'sql' => "varchar(255) NOT NULL default ''",
            ],
        ],
    ],
];

Developers

Guides

DCA reference
Custom table set up
Working with fieldpalette records (copying (parent) records)

Working with fieldpalette model

The FieldPaletteModel is not intended to be called directly and all custom methods are non static. We recommend to use the huh.fieldpalette.manager service.

Example:

/** 
 * @var ContainerInterface $container 
 */

// Return a model instance (with default table) for usage with model method (like find methods)
$container->get('huh.fieldpalette.manager')->getInstance()->findByPidAndTableAndField($item->id, 'tl_item', 'parentItem');

// Return a new model instance
$container->get('huh.fieldpalette.manager')->createModel()->findByPidAndTableAndField($item->id, 'tl_item', 'parentItem');

// Return a new model instance with custom table
$container->get('huh.fieldpalette.manager')->createModelByTable('tl_my_custom_table')->findByPidAndTableAndField($item->id, 'tl_item', 'parentItem');

Default model methods are still callable static. Custom method can also be called by creating a new model instance.

Widgets

Name Description
fieldpalette The FieldPaletteWizard renders the tl_fieldpalette items and provide crud functionality within its parent record (e.g. tl_news).

Fields

tl_fieldpalette:

Name Description
id autoincrement unique identifiere
pid id of the parent entry
ptable parent table name (e.g. tl_news)
pfield parent field name (e.g. tl_news.venues)
sorting the sorting value
published the published state (1 = published)
start timestamp from where the element is published
stop timestamp until the element is published

Form Callbacks

tl_fieldpalette:

Type Description
oncreate_callback Get fieldpalette key from request, check if the parent table is active within Fieldpalette Registry and set the pfield to tl_fieldpalette item.
onsubmit_callback Update/Sync parent fieldpalette item value (for example tl_news.venues) when tl_fieldpalette entries were updated.
oncut_callback Update/Sync parent fieldpalette item value (for example tl_news.venues) when tl_fieldpalette entries were sorted.
ondelete_callback Update/Sync parent fieldpalette item value (for example tl_news.venues) when tl_fieldpalette entries were deleted.

Hooks

Name Arguments Description
loadDataContainer $strTable Register fields from parent datacontainer (like tl_news) to tl_fieldpalette and disable fieldpalette support from back end modules where no fieldpalette fields exists (see: initializeSystem Hook).
initializeSystem - Enable tl_fieldpalette table within all back end modules.
executePostActions $strAction, DataContainer $dc Add refreshFieldPaletteField ajax action that return the updated FieldPaletteWizard content.

Restrictions

  • only supports DC_Table DataContainers

heimrichhannot/contao-fieldpalette-bundle 适用场景与选型建议

heimrichhannot/contao-fieldpalette-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.77k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2018 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「contao」 「fieldpalette」 「fieldgroup」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 heimrichhannot/contao-fieldpalette-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 heimrichhannot/contao-fieldpalette-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 heimrichhannot/contao-fieldpalette-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2018-03-14