承接 terminal42/dcawizard 相关项目开发

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

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

terminal42/dcawizard

Composer 安装命令:

composer require terminal42/dcawizard

包简介

dcaWizard extension for Contao Open Source CMS

README 文档

README

A backend widget for Contao that allows editors to manage records from a foreign database table directly within the parent record's edit form.

Installation

Install via Composer:

composer require terminal42/dcawizard

Basic Usage (DCA Example)

'prices' => [
    'inputType'    => 'dcaWizard',
    'foreignTable' => 'tl_iso_prices',
    'eval' => [
        'fields' => ['id', 'name', 'alias'],
    ],
],

Supporting both versions simultaneously

If your project needs to support both Contao 5.6 and 5.7+, you can allow both major versions using a version union constraint in your composer.json:

"require": {
    "terminal42/dcawizard": "^3.0 || ^4.0"
}

Composer will then automatically install:

  • 3.x when the project uses Contao ≤ 5.6
  • 4.x when the project uses Contao ≥ 5.7

No code changes are needed on your end — the correct version will be resolved based on the Contao version constraint in your own composer.json.

If you want to support both 3.x and 4.x simultaneously with a custom template, you need to set customTpl dynamically at runtime rather than statically in the DCA, since the template name changed between versions. For example, you can use an attributes callback to detect the installed version and return the correct template name:

<?php

use Composer\InstalledVersions;
use Contao\CoreBundle\DependencyInjection\Attribute\AsCallback;

#[AsCallback('tl_my_table', 'fields.my_field.attributes')]
class MyFieldAttributesListener
{
    public function __invoke(array $attributes): array
    {
        $isNewVersion = version_compare(InstalledVersions::getVersion('terminal42/dcawizard'), '4.0', '>=');

        $attributes['eval']['customTpl'] = $isNewVersion ? 'backend/widget/dcawizard_custom': 'be_widget_dcawizard_custom';

        return $attributes;
    }
}

Migrating from 3.x to 4.x

The 4.x release is largely backwards compatible.

The list_callback option has been removed. To customize the record list rendering, override the {% block record %} block in a custom template that extends the default one:

{# contao/templates/backend/widget/dcawizard_custom.html.twig #}
{% extends '@Contao/backend/widget/dcawizard.html.twig' %}

{% block record_value %}
    {# your custom rendering here #}
{% endblock %}

Then reference your template via customTpl:

'eval' => [
    'customTpl' => 'backend/widget/dcawizard_custom',
],

The default template name has also been renamed. If you have overridden it in your project, update it accordingly:

Version 3.x (.html5) Version 4.x (.html.twig)
be_widget_dcawizard backend/widget/dcawizard_custom

Configuration Reference

Top-level DCA Options

These options are set directly on the field definition, outside of eval.

Foreign Table Options

Option Type Default Description
foreignTable string - The foreign database table to manage records from.
foreignField string 'pid' The foreign key field linking child records to the parent (e.g. fid).
foreignTable_callback array - Callback to dynamically determine the foreign table name.

URL Params Options

Option Type Default Description
params array [] Additional URL parameters added to the popup link (e.g. do, custom filter fields).

eval Options

These options are set inside the eval array of the field definition.

Display Options

Option Type Default Description
fields string[] - Fields to display as columns in the record list.
headerFields string[] [] Custom column header labels. Leave empty to use field labels.
orderField string - Field (and direction) used to order records (e.g. name DESC).
emptyLabel string - Label displayed when no child records exist.

Button Options

Option Type Default Description
editButtonLabel string - Custom label for the edit/open popup button.
hideButton bool false Hides the popup button (record list display only).

Operations Options

Option Type Default Description
showOperations bool false Displays per-row operation buttons (edit, delete, etc.).
operations string[] all Limits which row operations are shown. Defaults to all available.
global_operations string[] [] Global operations added above the list (e.g. ['new']).

Template Options

Option Type Default Description
customTpl string be_widget_dcawizard Custom backend widget template name.

Full Configuration Example

'prices' => [
    'inputType' => 'dcaWizard',

    // Define the foreign table
    'foreignTable' => 'tl_iso_prices',

    // Define the foreign field (e.g. fid instead of pid)
    'foreignField' => 'fid',

    // Use a callback to determine the foreign table dynamically
    'foreignTable_callback' => ['tl_iso_prices', 'getTableName'],

    // Add special params to the popup button link
    'params' => [
        'do'          => 'member',
        'filterField' => 'group',
    ],

    'eval' => [
        // Fields to display in the list columns
        'fields' => ['id', 'name', 'alias'],

        // Custom column headers (leave empty to use field labels)
        'headerFields' => ['ID', 'Name', 'Alias'],

        // Custom label for the edit/open button
        'editButtonLabel' => $GLOBALS['TL_LANG']['tl_iso_products']['prices_edit_button'],

        // Label shown when no records exist
        'emptyLabel' => $GLOBALS['TL_LANG']['tl_iso_products']['prices_empty_label'],

        // Order records by a specific field
        'orderField' => 'name DESC',

        // Hide the popup button (show list only)
        'hideButton' => true,

        // Show per-row operations
        'showOperations' => true,

        // Limit which operations appear per row
        'operations' => ['edit', 'delete', 'new'],

        // Add global operations above the list
        'global_operations' => ['new'],

        // Use a custom widget template
        'customTpl' => 'backend/widget/dcawizard_custom',
    ],
],

Usage with DC_Multilingual

If the foreign table is managed by DC_Multilingual, use the dedicated input type to exclude translated duplicate entries from the list:

'inputType' => 'dcaWizardMultilingual',

If your setup uses a custom column name instead of the default language column (see langColumn in DC_Multilingual), specify it in the eval section:

'eval' => [
    'langColumn' => 'language_column_name',
],

Best Practices

  • Use foreignField when the linking column is not the default pid.
  • Use foreignTable_callback for dynamic table resolution (e.g. based on parent record type).
  • Use params to pre-filter the child record list via URL parameters.
  • Provide headerFields matching the count of fields for clarity.
  • Enable showOperations only when inline editing of individual rows is needed.

terminal42/dcawizard 适用场景与选型建议

terminal42/dcawizard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 385.2k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2013 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 terminal42/dcawizard 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 10
  • Watchers: 7
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2013-12-23