doujumiao5024 2018-06-01 14:37
浏览 75
已采纳

在TYPO3插件中创建新内容cType时使用FlexForm

I'm adding new content types to my TYPO3 and I want to use FlexForms to define each content type options form.

I have followed this example: https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/latest/AddingYourOwnContentElements/

And modified it to use FlexForms from this example: https://wiki.typo3.org/Extension_Development,_using_Flexforms

But I believe I don't quite understand the settings in Configuration/TCA/Overrrides/tt_contant.php:

// Adds content new content elements
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
    [
        'LLL:EXT:lu_content/Resources/Private/Language/locallang.xlf:contacts.title',
        'lu_content__contacts',
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('lu_content').'Resources/Public/Icons/Contacts.svg',
    ],
    'CType',
    'lu_content'
);

$GLOBALS['TCA']['tt_content']['types']['lu_content__contacts']['showitem']                       = 'CType;;;1-1-1,pi_flexform;;;1-1-1';
$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'][',lu_content__contacts'] = 'FILE:EXT:lu_content/Configuration/FlexForms/Contacts.xml';

The form works, but looks like this: enter image description here

How do I get the form not to fall under Plugin Options?

And how do I make the title/header to be used in to list view? Currently i get [notitle] after save in the content list.

enter image description here

Thank you in advance.

PS: I'm currently developing on TYPO3 v7 but with support for v8.

  • 写回答

1条回答 默认 最新

  • dstt1818 2018-06-09 08:38
    关注

    The Text for the tab as well as the arrangement of any tabs and fields is defined for general plugins in

    $GLOBALS['TCA']['tt_content']['types']['list']
    

    If you have defined an own CType it's quite probable that you wish to define own fields, palettes and types, hide standard-fields and perhaps replace default labels. The whole configuration for tt_content is quite complicated as it is used for all different content-elements and it can be seen in backend below System -> Configuration -> GLOBALS[TCA]:

    enter image description here

    The simplest option is to replace the label for the tab in $GLOBALS['TCA']['tt_content']['types']['list'].
    Before / Default:

    --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,--palette--;;general,--palette--;;headers,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin,list_type;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:list_type_formlabel,pages;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel,recursive,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;;frames,--palette--;;appearanceLinks,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,--palette--;;language,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,--palette--;;hidden,--palette--;;access,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,--div--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,categories,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,rowDescription,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended
    

    After / location to fill with own label: (look for ###YOUR_LABEL###):

    --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,--palette--;;general,--palette--;;headers,--div--;###YOUR_LABEL###,list_type;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:list_type_formlabel,pages;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel,recursive,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;;frames,--palette--;;appearanceLinks,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,--palette--;;language,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,--palette--;;hidden,--palette--;;access,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,--div--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,categories,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,rowDescription,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended
    

    and a more difficult approach would be to define an own type in $GLOBALS['TCA']['tt_content']['types'].

    Here you find The documentation about TCA.

    For your case are especially interesting the following chapters:

    But if you want to change labels or other configuration of single fields you'd had to refer to the chapter / configuration about columns.
    In the area ctrl you still can define some general options like sorting-fields or the behavior when the whole element is copied, have a look in that chapter to get an impression about all options. Also the desired and default label and value-field is configured there with

    $GLOBALS['TCA']['tt_content']['ctrl']['label']
    

    its also possible to combine two or more fields for the default display:

    $GLOBALS['TCA']['tt_content']['ctrl']['label'] = 'header';
    $GLOBALS['TCA']['tt_content']['ctrl']['label_alt'] = 'subheader';
    

    you might still want to add the option

    $GLOBALS['TCA']['tt_content']['ctrl']['label_alt_force'] = 1;
    

    Configuring the form for a plugin can take quite some time even to understand all the options, but in general there are very much options to individualize it related to many needs. It's even possible to define user-functions to handle and display own options in the form which are not covered by the existing options.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?