Typo3 10.4.1 用一个文件ref扩展页面。

问题描述 投票:0回答:1

希望有知情人能看到这个。

任务很简单,但出了点问题,我写了一个扩展,为每个页面扩展页面表,并添加了一些新的道具,这些道具包括:1个布尔值(extension active)1个文本值(如css类名称)1个Filelink to sys_file for uploaded images。

这些值是:1 布林值(是否扩展活动)1 文本值(如css类名称)1 上传图片的sys_file的文件链接。

后台的字段本身也能正常工作。后台的字段但如果我在前台通过流体访问它们,只有一个孤独的1(Int)保存?

在Fluid中:{data.TX_mnadditionalpagefields_extended_background_image}。

导致这个-> 1 (整数)

我做错了什么?

我的ext_tables.sql

CREATE TABLE pages (
    tx_mnadditionalpagefields_custom_css_class varchar(255) DEFAULT '' NOT NULL,
    tx_mnadditionalpagefields_activate_extended_rules TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL,
    tx_mnadditionalpagefields_extended_background_image int(11) unsigned NOT NULL default '0'
);

my ext...ConfigurationTCAOverridespages.php

<?php

defined('TYPO3_MODE') or die();

// Configure new fields:
$fields = [
    'tx_mnadditionalpagefields_custom_css_class' => [
        'label' => 'LLL:EXT:nm_addtional_page_fields/Resources/Private/Language/locallang_db.xlf:pages.tx_mnadditionalpagefields_custom_css_class',
        'exclude' => 1,
        'config' => [
            'type' => 'input',
            'max' => 255
        ],
    ],
    'tx_mnadditionalpagefields_activate_extended_rules' => [
        'exclude' => 1,
        'label' => 'LLL:EXT:nm_addtional_page_fields/Resources/Private/Language/locallang_db.xlf:pages.tx_mnadditionalpagefields_activate_extended_rules',
        'config' => [
            'type' => 'check',
            'default' => 0
        ]
    ],
    'tx_mnadditionalpagefields_extended_background_image' => [
        'exclude' => 1,
        'label' => 'LLL:EXT:nm_addtional_page_fields/Resources/Private/Language/locallang_db.xlf:pages.tx_mnadditionalpagefields_extended_background_image',
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'tx_mnadditionalpagefields_extended_background_image',
            [
                'maxitems' => 1,
                'minitems' => 0,
                'appearance' => [
                    'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'
                ],
                //'foreign_match_fields' => array(
                //    'fieldname' => 'tx_mnadditionalpagefields_extended_background_image',
                //    'tablenames' => 'pages',
                //    'table_local' => 'sys_file',
                //),
            ],
            $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
        ),
    ]
];

// Add new fields to pages:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $fields);

// Make fields visible in the TCEforms:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
    'pages', // Table name
    '--palette--;LLL:EXT:nm_addtional_page_fields/Resources/Private/Language/locallang_db.xlf:pages.palette_title;nm_addtional_page_fields', // Field list to add
    '1', // List of specific types to add the field list to. (If empty, all type entries are affected)
    'after:nav_title' // Insert fields before (default) or after one, or replace a field
);

// Add the new palette:
$GLOBALS['TCA']['pages']['palettes']['nm_addtional_page_fields'] = [
    'showitem' => 'tx_mnadditionalpagefields_activate_extended_rules,tx_mnadditionalpagefields_custom_css_class,tx_mnadditionalpagefields_extended_background_image'
];

扩展下载(WIP)。下载(WIP):

typo3 typo3-10.x
1个回答
0
投票

对于imagesfiles,本地表只存储文件引用的数量。(int)1表示,有 一个 引用。

请看一下DataProcessing,了解如何用Fluid使用这些文件引用。https:/docs.typo3.orgctypo3cms-coremasteren-usChangelog7.4Feature-67662-DataProcessorForFiles.html。

© www.soinside.com 2019 - 2024. All rights reserved.