简体   繁体   English

为TYPO3中的内容元素提供更多样式选项

[英]Offer more styling options for content element in TYPO3

In past I used the Visual Composer with WordPress very often. 过去,我经常在WordPress中使用Visual Composer。 Now I am trying my first development with TYPO3. 现在,我正在尝试使用TYPO3进行第一个开发。

I've developed a content element. 我已经开发了一个内容元素。 Everything works fine. 一切正常。 But now I want to offer the editor more options for styling. 但是现在我想为编辑器提供更多样式选项。

For example: - CSS classes - Colors - Sizes - Paddings - Margins 例如:-CSS类-颜色-尺寸-填充-边距

This information should be accessable in the fluid template. 该信息应可在流体模板中访问。 Is this possible? 这可能吗? Maybe in an additional tab? 也许在其他标签中?

You have to add fields to the tt_content table. 您必须将字段添加到tt_content表。 For that you can use TCA. 为此,您可以使用TCA。 There is even a good example in the TYPO3 documentation to extend tt_content with a "No print" checkbox. TYPO3文档中甚至有一个很好的示例,它使用“不打印”复选框扩展了tt_content。

Write your fields database specification in the ext_tables.sql file: 在ext_tables.sql文件中编写字段数据库规范:

CREATE TABLE tt_content (
        tx_your_extension_no_border tinyint(4) DEFAULT '0' NOT NULL
);

Then you need an other file in your extension in this path: your_extension/Configuration/TCA/Overrides/tt_content.php 然后,您需要在此路径的扩展名中包含另一个文件: your_extension / Configuration / TCA / Overrides / tt_content.php

And you can add the fields defined up there here: 您可以在此处添加定义的字段:

$temporaryColumn = array(
        'tx_your_extension_no_border' => array (
                'exclude' => 0,
                'label' => 'LLL:EXT:your_extension/Resources/Private/Language/locallang_db.xlf:tt_content.tx_your_extension_no_border',
                'config' => array (
                        'type' => 'check',
                 )
            )
    );
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
            'tt_content',
            $temporaryColumn
    );
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
            'tt_content',
            'visibility',
            'tx_your_extension_no_border',
            'after:linkToTop'
    );

See the whole documentation here . 请在此处查看整个文档。

Some explanation: 一些解释:

The function " addTCAcolumns " registers your "temp columns" to the table. 函数“ addTCAcolumns ”将您的“临时列”注册到表中。

The function " addFieldsToPalette " adds your field "tx_your_extension_no_border" into a "palette". 函数“ addFieldsToPalette ”将字段“ tx_your_extension_no_border”添加到“调色板”中。 (You can read about Palettes here ). (您可以在此处阅读有关调色板的信息 )。

The first parameter is the table. 第一个参数是表格。 (tt_content) (tt_content)

The second parameter is the name of the palette (here it is the visibility) 第二个参数是调色板的名称(这里是可见性)

The third is the field name (tx_your_extension_no_border) 第三个是字段名称(tx_your_extension_no_border)

The forth is a position. 第四是位置。 You can use after and before to place your field exact befor XY field. 您可以在之后和之前使用字段来精确放置XY字段之前的字段。

Of course you can add your own tabs as well. 当然,您也可以添加自己的标签。

The syntax is: --div--<tab_name>,<fields> 语法为: --div--<tab_name>,<fields>

Fluid: 流体:

After you added the fields they are accessible in your fluid templates just like any other tt_content fields. 添加字段后,就可以像其他任何tt_content字段一样在流体模板中访问它们。 You can use if-s, layouts, sections to enable the variety to the editors as they work with your content element. 您可以使用if-s,布局,节来使编辑器在与您的内容元素一起使用时具有多样性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM