基于TCA记录的TYPO3自动页面创建 [英] TYPO3 automatic page creation based on TCA record

查看:30
本文介绍了基于TCA记录的TYPO3自动页面创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对我的项目有特殊要求,需要帮助.我正在使用 TYPO3 8.7.8.我有一个自定义扩展来在前端呈现标签标签.我们可以在后端存储文件夹中添加标签作为 TCA 记录.在 TCA 记录中,您可以标记名称.我的要求是,当我保存 TCA 记录时,我想在特定位置自动创建一个与标签同名的 TYPO3 页面.每次添加 TCA 记录时,都需要自动创建相应的页面.这可能吗?我可以在保存 TCA 的同时使用钩子.但是有没有自动创建页面的功能?

I've special requirement on my project and I need help. I am using TYPO3 8.7.8. I've a custom extension to render tag labels in frontend. We can add the tags as TCA record in backend storage folder. In the TCA record, you can tag name. My requirement is, when I save the TCA record I want to create a TYPO3 page automatically with the same name as tag in a specific position. Everytime when I add a TCA record, I need to create corresponding page automatically. Is this possible? I can use hook while saving TCA. But is there any function to create pages automatically?

自动创建页面后,我想在该页面中自动插入一个具有特定 flexform 值的插件内容元素.我知道这是一个奇怪的要求,但我想知道是否可能.

After automatic page creation, I want to insert a plugin content element in that page with a specific flexform value automatically. I know this is a strange requirement, but I would like to know if it is possible or not.

推荐答案

确切地说,您将在保存时触发挂钩,然后在下一步中您可以使用数据处理程序生成新页面(和可能的内容).

Exactly, you'd trigger a hook on saving and then as next step you can use the data handler to generate the new page (and possible content).

要创建页面和内容,请使用类似于以下数据结构的内容

To create the page and content, use something like the following data structure

$data = [
   'pages' => [
       'NEW_1' => [
           'pid' => 456,
           'title' => 'Title for page 1',
       ],
    ],
    'tt_content' => [
        'NEW_123' => [
           'pid' => 'NEW_1',
           'header' => 'My content element',
        ],
    ],
];

然后使用该结构调用数据处理程序:

Then call the datahandler with that structure:

$tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
$tce->stripslashes_values = 0;
$tce->start($data, []);
$tce->process_datamap();

在文档中了解更多信息https://docs.typo3.org/Typo3cms/CoreApiReference/ApiOverview/Typo3CoreEngine/Database/Index.html#data-arrayhttps://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Typo3CoreEngine/UsingDataHandler/Index.html

Find out more in the docs at https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Typo3CoreEngine/Database/Index.html#data-array and https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Typo3CoreEngine/UsingDataHandler/Index.html

这篇关于基于TCA记录的TYPO3自动页面创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆