【问题标题】:TYPO3 - Attempt to insert record on page where this table is not allowedTYPO3 - 尝试在不允许此表的页面上插入记录
【发布时间】:2022-06-10 20:45:17
【问题描述】:

我用“sitepackage builder”做了一个新的扩展来覆盖扩展“bootstrap_package”。

如果我只是在sitepackage 中更改/覆盖bootstrap_package 的某些文件中的代码,则会显示内容元素并显示我的更改。 但是如果我在sitepackage builder 中添加一个新的内容元素,我就会遇到一些问题。

我添加了一个向导“Carousel Small XXX”和页面“Carousel”上的一些字段,如下所示:

如果我创建一个项目并更改“文本和图像”之类的类型,则会出现错误:

1: Attempt to insert record on page 'Carousel' (101) where this table, tx_carousel_item_xx, is not allowed

此外,我的内容元素“Carousel Small XXX”未显示在前端。 一个表“tx_carousel_item_xx”在数据库中,但是数据库中没有数据(数据没有保存)。

我试过这些:

  1. 在 ext_tables.php 中
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_carousel_item_xx');
$TCA['tx_carousel_item_xx']['ctrl']['security']['ignoreRootLevelRestriction'] = 1; 
$TCA['tx_carousel_item_xx']['ctrl']['rootLevel'] = -1; 
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('sys_file_reference');
$TCA['sys_file']['ctrl']['security']['ignoreRootLevelRestriction'] = 1; 
$TCA['sys_file']['ctrl']['rootLevel'] = -1; 
$TCA['sys_file_reference']['ctrl']['security']['ignoreRootLevelRestriction'] = 1; 
$TCA['sys_file_reference']['ctrl']['rootLevel'] = -1; 
  1. 在 TCA 中
$GLOBALS['TCA']['tt_content']['types']['carousel_small_xx'] = array_replace_recursive(
    $GLOBALS['TCA']['tt_content']['types']['carousel_small_xx'],
    [
        'showitem' => '
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.headers;headers,
                tx_carousel_item_xx,
            --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel.options,
                pi_flexform;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:advanced,
            --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.appearanceLinks;appearanceLinks,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
                --palette--;;language,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
                --palette--;;hidden,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
                categories,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
                rowDescription,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
        '
    ]
);

$GLOBALS['TCA']['tt_content']['columns'] = array_replace_recursive(
    $GLOBALS['TCA']['tt_content']['columns'],
    [
        'tx_carousel_item_strobelmuehle' => [
            'exclude' => 1,
            'label' => 'LLL:EXT:myextension/locallang_db.xml:company.employees',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_carousel_item_strobelmuehle',
                'foreign_field' => 'pid',
                'foreign_table_field' => 'tt_content',
                'appearance' => [
                    'collapseAll' => 1,
                    'expandSingle' => 1,
                ],
            ],
        ],
    ]
);
  1. 在 tsconfig 中
mod.web_list.allowedNewTables = tt_content, pages, tx_carousel_item_xx
  1. 在数据库中添加新表
CREATE TABLE tx_carousel_item_xx (
    uid int(11) unsigned NOT NULL auto_increment,
    pid int(11) DEFAULT '0' NOT NULL,
    tt_content int(11) unsigned DEFAULT '0',
    ...
    PRIMARY KEY (uid),
    KEY parent (pid),
    KEY t3ver_oid (t3ver_oid,t3ver_wsid),
    KEY language (l10n_parent,sys_language_uid)
);

  1. 排版
tt_content.carousel_small_xx >
tt_content.carousel_small_xx =< lib.contentElement
tt_content.carousel_small_xx {
    templateName = CarouselSmallxx
    dataProcessing {
        10 = BK2K\BootstrapPackage\DataProcessing\FlexFormProcessor
        20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
        20 {
            table = tx_carousel_item_xx
            pidInList.field = pid
            where {
                data = field:uid
                intval = 1
                wrap = tt_content=|
            }
            orderBy = sorting
            dataProcessing {
                10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                10 {
                    references.fieldName = background_image
                    as = backgroundImage
                }
                20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                20 {
                    references.fieldName = image
                    as = images
                }
                1532633187 = BK2K\BootstrapPackage\DataProcessing\FlexFormProcessor
                1532633187 {
                    fieldName = background_image_options
                }
            }
        }
}

我阅读了一些关于此问题的文章并更改了 ext_tables.php 中的 roorlevel。 但是每次都会出现错误消息。谁能帮我解决这个问题?

请检查我的数据库代码。 如果我在我的新内容元素中添加了一条记录,我无法将数据保存在表“tx_carousel_item_xx”中。表的数据库好像是:enter image description here

此外,我不确定我在 TCA 中的代码。尤其是'foreign_table'、'foreign_field'和'foreign_table_field'。

我在我的数据库中添加了一个“tx_carousel_item_xx”表示的新表。我在“tt_content”中添加了一列“tx_carousel_item_xx”。如果我在 TCA 中使用 'type' =&gt; 'inline',我还需要一张表吗?我应该在 'foreign_table'、'foreign_field' 和 'foreign_table_field' 中写哪些表?

提前谢谢你。

【问题讨论】:

    标签: php typo3


    【解决方案1】:

    尝试在 ext_tables.php 文件中将 $TCA 替换为 $GLOBALS['TCA']

    【讨论】:

    • 感谢您的回答。我将代码更改为$GLOBALS['TCA']['tx_carousel_item_strobelmuehl']['ctrl']['rootLevel'] = -1; (当然其他代码也使用$GLOBALS['TCA']),但错误仍然出现......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-19
    • 2011-07-10
    • 2015-03-03
    • 1970-01-01
    • 2020-03-05
    相关资源
    最近更新 更多