Typo3 Type3 8.7:使用新字段扩展系统类别
我只是想用一个新字段“page”扩展sys_category表,就像普通的extbase方法一样。像一个魔咒一样工作,字段显示并保存在DB中。但在流体中的f:debug中没有字段。有人知道少了什么吗 非常感谢你的帮助 TCA覆盖:Typo3 Type3 8.7:使用新字段扩展系统类别,typo3,extbase,typo3-8.x,typo3-extensions,Typo3,Extbase,Typo3 8.x,Typo3 Extensions,我只是想用一个新字段“page”扩展sys_category表,就像普通的extbase方法一样。像一个魔咒一样工作,字段显示并保存在DB中。但在流体中的f:debug中没有字段。有人知道少了什么吗 非常感谢你的帮助 TCA覆盖: $newColumns = [ 'page' => [ 'exclude' => true, 'label' => 'LLL:EXT:project/Resources/Private/Language/Default/local
$newColumns = [
'page' => [
'exclude' => true,
'label' => 'LLL:EXT:project/Resources/Private/Language/Default/locallang_db.xlf:sys_category.page',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'pages',
'size' => 1,
'maxitems' => 1,
'minitems' => 0
]
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_category', $newColumns);
// Make fields visible in the TCEforms:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'sys_category', // Table name
'page', // Field list to add
'1', // List of specific types to add the field list to. (If empty, all type entries are affected)
'after:title' // Insert fields before (default) or after one, or replace a field
);
SQL:
型号:
<?php
namespace <Vendorname>\Project\Domain\Model;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
/**
* Class Category
* @package <Vendorname>\Project
*/
class Category extends \TYPO3\CMS\Extbase\Domain\Model\Category
{
/**
* @var integer
*/
protected $page = null;
/**
* Gets the page.
*
* @return integer
* @api
*/
public function getPage()
{
return $this->page;
}
/**
* Sets the page.
*
* @param integer $page
* @api
*/
public function setPage($page)
{
$this->page = $page;
}
}
我不确定是否可以将TYPO3的系统分类表划分为子类
如果您总是希望到TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository的所有查询将返回自定义类型的对象,您可以配置ext\u typoscript\u设置,如下所示
config.tx_extbase{
objects {
TYPO3\CMS\Extbase\Domain\Model\Category.className = <vendor>\Project\Domain\Model\Category
}
persistence.classes {
<vendor>\Project\Domain\Model\Category {
mapping {
tableName = sys_category
}
}
}
}
config.tx\u extbase{
物体{
TYPO3\CMS\Extbase\Domain\Model\Category.className=\Project\Domain\Model\Category
}
持久性类{
\项目\域\模型\类别{
映射{
tableName=sys\u类别
}
}
}
}
请注意,这将不包括表中由其他TYPO3扩展名生成的任何其他扩展名sys\u category
但是,如果您只需要扩展中的扩展的类别
对象,而不是TYPO3中的全局对象,那么您可以在扩展中创建自己的CategoryRepository,如找到问题的解决方案了吗?现在我想做同样的事情。。。
config.tx_extbase.persistence {
storagePid = {$plugin.tx_project.persistence.storagePid}
classes {
TYPO3\CMS\Extbase\Domain\Model\Category {
subclasses {
<Vendorname>\Project\Domain\Model\Category = <Vendorname>\Project\Domain\Model\Category
}
}
<Vendorname>\Project\Domain\Model\Category {
mapping {
tableName = sys_category
}
}
}
}
config.tx_extbase{
objects {
TYPO3\CMS\Extbase\Domain\Model\Category.className = <vendor>\Project\Domain\Model\Category
}
persistence.classes {
<vendor>\Project\Domain\Model\Category {
mapping {
tableName = sys_category
}
}
}
}