TYPO3:在TCA

时间:2019-05-15 10:02:58

标签: typo3 typo3-8.x

当前的问题与TCA及其addRecord选项有关,后者应将新记录保存到###PAGE_TSCONFIG_ID###配置的特定pid中。 (TYPO3 8.7.24,php 7.2)

websites扩展名具有tx_rwfm_domain_model_websitecategorytx_rwfm_domain_model_website表,它们通过m:m表关联。这个想法是创建网站类别,然后收集分配给类别的网站。在BE中,类别(pid = 24)和网站(pid = 12)在网站树中都有自己的文件夹。 websitecategory具有multiSelectField,可以轻松选择网站并将其分配给相关类别。另外,“网站”还具有用于类别的multiSelectField,可以轻松地将网站分配给多个类别。

到目前为止,一切正常。

现在我碰到这种情况:

  • 我想将网站添加到类别中,因此我在列表视图中打开websitecategory文件夹页面。

  • 我现在意识到我要添加的网站尚未创建。

  • 我没有关闭websitecategory页面,而是单击了websites(m:m连接)的multiSelectField旁边的“ addRecord”

  • 打开一个新窗口以创建新网站,“保存并关闭”将我带回到网站类别页面,在那里我可以看到新网站已添加到选择列表中。

重点是:新网站必须在其自己的文件夹页面(pid = 12)中创建,而不是在websitecategory页面(pid = 24)中创建。为此,有一个属性###PAGE_TSCONFIG_ID###,我尝试这样配置:

// TCA of websitecategory

return [
  [...],
  'columns' => [
    'websites' => [
      'config' => [
        'type' => 'select',
        'renderType' => 'selectMultipleSideBySide',
        'enableMultiSelectFilterTextfield' => true,
        'foreign_table' => 'tx_rwfm_domain_model_website',
        'foreign_table_where' => 'AND tx_rwfm_domain_model_website.sys_language_uid IN (-1,0) ORDER BY tx_rwfm_domain_model_website.title ASC',
        'MM' => 'tx_rwfm_domain_model_website_websitecategory_mm',
        'MM_opposite_field' => 'categories',
        'fieldControl' => [
          'editPopup' => [...],
          'addRecord' => [
            'disabled' => false,
            'options' => [
              'setValue' => 'prepend',
              'title' => 'Create a new website record',
              'table' => 'tx_rwfm_domain_model_website',
              'pid' => '###PAGE_TSCONFIG_ID###',
            ],
          ],
        ]
      ]
    ]
    [...]
]

按照文档https://docs.typo3.org/typo3cms/TSconfigReference/8.7/PageTsconfig/TCEform/Index.html?highlight=page_tsconfig_id,我将其添加到我的页面TSconfig:

// TSconfig

TCEFORM {
    tx_rwfm_domain_model_website {
        pid.PAGE_TSCONFIG_ID = 12
    }
    tx_rwfm_domain_model_websitecategory {
        pid.PAGE_TSCONFIG_ID = 28
    }
}

不幸的是,这不起作用。而是,TYPO3尝试将其添加到[root_level] 0, where the table is not allowed。 但是,如果我将###PAGE_TSCONFIG_ID###-> TCA中的addRecord替换为pid的硬编码值12,则该网站的确会保存在正确的页面文件夹中, pid 12。

我必须如何配置TSconfig才能使保存过程正确地工作?

3 个答案:

答案 0 :(得分:0)

就我阅读的源代码而言,这仅适用于foreign_table_where中定义的值。

答案 1 :(得分:0)

经过一段漫长的时间(实际上是几年!),我终于明白了,您需要将PID_TSCONFIG_ID分配给的字段必须是那个字段,它是m:m关系。或者:相反的领域。更令人困惑的是,根据定义,相反字段只能在关系的一侧进行定义。因此,对于“另一面”,您需要查看相关表的名称并使用该名称。

在上面的示例中,这意味着必须使用categories代替pid

// TSconfig

TCEFORM {
  tx_rwfm_domain_model_website {
    categories.PAGE_TSCONFIG_ID = 12
  }
  tx_rwfm_domain_model_websitecategory {
    websites.PAGE_TSCONFIG_ID = 28
  }
}

这样,记录将保存到给定的页面ID。 TYPO3,感谢您提供有关该主题的神秘文档! :-( 将尝试尽快改善这方面的文档。

答案 2 :(得分:0)

在常量 select a.day as day,b.id as id from table1 a cross join table1 b where a.id <> b.id and (a.id,a.day) in (select id,day from original_table where `day` = '2019-08-01'); 之前使用pid作为表引用很可能是您要解决的错误字段。所以这个:

PAGE_TSCONFIG_ID

应该变成这样:

TCEFORM {
    tx_rwfm_domain_model_website {
        pid.PAGE_TSCONFIG_ID = 12
    }
    tx_rwfm_domain_model_websitecategory {
        pid.PAGE_TSCONFIG_ID = 28
    }
}
相关问题