1

我正在尝试使用 TYPO3 的 DataHandler 数据结构(使用 TYPO3 v7 测试)创建嵌套记录结构。但是,关系并未按预期创建。考虑以下数据结构:

        $data = array(
                'sys_category' =>
                        array(
                                'NEW_1' =>
                                        array(
                                                'title' => 'Category 1',
                                                'pid' => $pid,
                                        ),
                                'NEW_2' =>
                                        array(
                                                'title' => 'Category 3',
                                                'pid' => $pid,
                                        ),
                                'NEW_3' =>
                                        array(
                                                'title' => 'Category 2',
                                                'pid' => $pid,
                                        ),
                                'NEW_4' =>
                                        array(
                                                'title' => 'Category 1.1',
                                                'pid' => $pid,
                                                'parent' => 'NEW_1',
                                        ),
                                'NEW_5' =>
                                        array(
                                                'title' => 'Category 1.2',
                                                'pid' => $pid,
                                                'parent' => 'NEW_1',
                                        ),
                                'NEW_6' =>
                                        array(
                                                'title' => 'Category 3.1',
                                                'pid' => $pid,
                                                'parent' => 'NEW_2',
                                        ),
                        ),
        );

这在数据库中给出了以下结果:

uid title           parent
1   Category 1      0
2   Category 3      0
3   Category 2      0
4   Category 1.1    0
5   Category 1.2    0
6   Category 3.1    0

请注意所有“父”字段的“0”值。为什么不为数据结构中设置的“父”字段解释“NEW_*”值?

4

2 回答 2

1

As mentioned in a comment above, the situation changed between TYPO3 6.2 and 7.6. The difference lies in \TYPO3\CMS\Core\DataHandling\DataHandler::processRemapStack(). Starting with TYPO3 7.6, it checks if the "NEW*" placeholders contain a low dash (_). If yes, the placeholder is split on that character and the first part of the string is considered to be the related table name.

This is a change from before, where the low dash had no special meaning. Indeed, the documentation mentions examples using a low dash.

So the above code works fine with just removing the low dash from all the placeholders.

于 2017-03-30T12:40:07.660 回答
0

据我所知,只有 pid-value 被检查为“NEW”-keyword。但是您也可以使用一些包含的钩子来启用“父”的分配。

编辑:我指的是 TYPO3\CMS\Core\DataHandling\DataHandler::process_datamap()

于 2017-03-29T12:40:36.347 回答