简体   繁体   English

TYPO3自定义页面属性

[英]TYPO3 Custom Page Properties

I'm trying to make the Publish Date mandatory for my "Article" page type. 我试图将“文章”页面类型的发布日期设为必填项。

I added this code 我添加了这段代码

$fields_article = array(
    'starttime' => [
        'label' => 'Publish Date',
        'config' => [
            'type' => 'input',
            'eval' => 'datetime,required'
        ],
    ]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $fields_article);
$showItem = "--div--;Page Settings";
$showItem .= ",--linebreak--,starttime";
$GLOBALS['TCA']['pages']['types'][$doktypeArticlePage] = array(
    'showitem' => $showItem
);

And this works, but it makes the Publish Date mandatory for all page types. 这行得通,但是它使所有页面类型的“发布日期”为必填项。 Is it possible to only add the required tag to article page types? 是否可以仅将必需的标记添加到文章页面类型?

There is no default way to set eval based on type, so I'm afraid there's no easy way to do this. 没有基于类型设置eval的默认方法,因此,恐怕没有简单的方法可以执行此操作。

You could most likely do this with a custom eval. 您很可能可以通过自定义评估来执行此操作。 See the Vendor\\Extention\\* section in https://docs.typo3.org/typo3cms/TCAReference/latest/ColumnsConfig/Type/Input.html#eval for more information about that. 有关更多信息,请参见https://docs.typo3.org/typo3cms/TCAReference/latest/ColumnsConfig/Type/Input.html#eval中Vendor\\Extention\\*部分。

Alternatively you could create a new required field, which is only shown in your "Article" page type, and use one of the hook in TYPO3\\CMS\\Core\\DataHandling\\DataHandler to copy its value to the starttime field. 或者,您可以创建一个新的必填字段,该字段仅显示在“文章”页面类型中,并使用TYPO3\\CMS\\Core\\DataHandling\\DataHandler其中一个钩子将其值复制到starttime字段。

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

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