我正在处理文件列表扩展,并想知道我是否可以为特定文件类型(如pdf)或特定子文件夹中的所有文件设置其他元数据。
到目前为止,我已使用以下设置扩展了sys_file_metadata:
ext_tables.sql
CREATE TABLE sys_file_metadata (
tags int(11) unsigned DEFAULT '0' NOT NULL,
type int(11) unsigned DEFAULT '0'
);
CREATE TABLE sys_file_metadata_tags_mm (
uid_local int(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
sorting int(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);
sys_file_metadata.php
<?php
defined('TYPO3_MODE') || die();
$l1 = 'LLL:EXT:file_portal/Resources/Private/Language/locallang_db.xlf:';
$additionalColumns = [
'tags' => [
'exclude' => 1,
'label' => $l1 . 'tx_fileportal_domain_model_file.tags',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_fileportal_domain_model_tag',
'MM' => 'tx_fileportal_fileallocation_tag_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'wizards' => [
'_PADDING' => 1,
'_VERTICAL' => 1,
'edit' => [
'module' => [
'name' => 'wizard_edit',
],
'type' => 'popup',
'title' => 'Edit',
'icon' => 'edit2.gif',
'popup_onlyOpenIfSelected' => 1,
'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
],
'add' => [
'module' => [
'name' => 'wizard_add',
],
'type' => 'script',
'title' => 'Create new',
'icon' => 'add.gif',
'params' => [
'table' => 'tx_fileportal_domain_model_tag',
'pid' => '###CURRENT_PID###',
'setValue' => 'prepend'
],
],
],
],
],
'type' => [
'exclude' => 1,
'label' => $l1 . 'tx_fileportal_domain_model_file.type',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_fileportal_domain_model_filetype',
'minitems' => 0,
'maxitems' => 1,
'items' => [
['Bitte wählen', 0]
],
'appearance' => [
'collapseAll' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
]
]
]
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_file_metadata', $additionalColumns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('sys_file_metadata', 'tags, type');
return $GLOBALS['TCA']['sys_file_metadata'];
这很有效,我可以为我的文件添加一些自定义标签和自定义更具体的类型,但是此选项现在可用于我的所有文件。有没有办法只针对特定文件类型或特定子文件夹中的文件显示此选项,可能有显示条件?
答案 0 :(得分:0)
你可以在TCA中使用displayCond。查看documentation。
如果要依赖某个字段,则应将该字段添加到表的TCA中ctrl部分的requestUpdate选项中。查看documentation
现在,如果更改了该字段的值,则会要求您重新加载表单,因为字段可能会更改。
答案 1 :(得分:0)
我不知道如何添加&#34; requestUpdate&#34;到sys_file_metadata的TCA,因为ExtensionManagementUtility不包含这样的东西或者我错了吗?到目前为止,显示条件对我来说是有用的,为了完整起见,这是我的条件示例:
<?php
defined('TYPO3_MODE') || die();
$l1 = 'LLL:EXT:file_portal/Resources/Private/Language/locallang_db.xlf:';
$additionalColumns = [
'downloadable' => [
'exclude' => 1,
'label' => $l1. 'tx_fileportal_domain_model_file.downloadable',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['No', 0],
['Yes', 1],
],
'minitems' => 0,
'maxitems' => 1
]
],
'tags' => [
'displayCond' => 'FIELD:downloadable:>:0',
'exclude' => 1,
'label' => $l1 . 'tx_fileportal_domain_model_file.tags',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_fileportal_domain_model_tag',
'MM' => 'sys_file_metadata_tag_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'wizards' => [
'_PADDING' => 1,
'_VERTICAL' => 1,
'edit' => [
'module' => [
'name' => 'wizard_edit',
],
'type' => 'popup',
'title' => 'Edit',
'icon' => 'edit2.gif',
'popup_onlyOpenIfSelected' => 1,
'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
],
'add' => [
'module' => [
'name' => 'wizard_add',
],
'type' => 'script',
'title' => 'Create new',
'icon' => 'add.gif',
'params' => [
'table' => 'tx_fileportal_domain_model_tag',
'pid' => '###CURRENT_PID###',
'setValue' => 'prepend'
],
],
],
],
],
'type' => [
'displayCond' => 'FIELD:downloadable:>:0',
'exclude' => 1,
'label' => $l1 . 'tx_fileportal_domain_model_file.type',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_fileportal_domain_model_filetype',
'minitems' => 0,
'maxitems' => 1,
'items' => [
['Choose', 0]
],
'appearance' => [
'collapseAll' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
]
]
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_file_metadata', $additionalColumns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'sys_file_metadata', 'downloadable, tags, type'
);
return $GLOBALS['TCA']['sys_file_metadata'];