简体   繁体   English

TYPO3基于TCA记录的自动页面创建

[英]TYPO3 automatic page creation based on TCA record

I've special requirement on my project and I need help. 我对项目有特殊要求,需要帮助。 I am using TYPO3 8.7.8. 我正在使用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. 我们可以将标签作为TCA记录添加到后端存储文件夹中。 In the TCA record, you can tag name. 在TCA记录中,您可以标记名称。 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. 我的要求是,当我保存TCA记录时,我想在特定位置自动创建一个与标签同名的TYPO3页面。 Everytime when I add a TCA record, I need to create corresponding page automatically. 每次添加TCA记录时,我需要自动创建相应的页面。 Is this possible? 这可能吗? I can use hook while saving TCA. 保存TCA时可以使用钩子。 But is there any function to create pages automatically? 但是有自动创建页面的功能吗?

After automatic page creation, I want to insert a plugin content element in that page with a specific flexform value automatically. 自动创建页面后,我想在该页面中自动插入具有特定flexform值的插件内容元素。 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();

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 https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Typo3CoreEngine/Database/Index.html#data-arrayhttps://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview的文档中找到更多信息。 /Typo3CoreEngine/UsingDataHandler/Index.html

Are you sure you need additional pages? 您确定需要其他页面吗?

In general your problem sounds like you need one page where the plugin is inserted and where the plugin in dependency of an url-parameter (which can be converted with realurl into a path segment) shows only information depending of the selected record (tag). 通常,您的问题听起来好像需要插入插件的页面以及依赖于url参数(可以使用realurl转换为路径段的依赖)的插件在其中仅显示取决于所选记录(标签)的信息的页面。

If no tag is selected you can output a list with all available tags as a menu to navigate to all possible tags. 如果未选择标签,则可以输出包含所有可用标签的列表作为菜单,以导航到所有可能的标签。

With a little effort (less than writing a hook like intended) you can add all tags to your menu. 只需花费一点功夫(而不是像预期的那样编写钩子),就可以将所有标签添加到菜单中。

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

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