TYPO3:如何扩展sys_file_collection?

时间:2018-11-01 16:30:55

标签: typo3 fluid typo3-8.x

我想将其他字段添加到TYPO3文件集合中。
我用this Documentation进行了尝试,并将字段添加到了TCA和数据库中。 只要我仅在后端,这就可以正常工作。但是在Fluid中,我无法访问新闻栏。
下一步是我尝试扩展模型以使其字段具有getter和setter,并设置extbase以使用模型Class。但是TYPO3忽略了它。

StaticFileCollection.php

class StaticFileCollection extends \TYPO3\CMS\Core\Resource\Collection\StaticFileCollection
{
/**
 * Subheader
 *
 * @var string
 */
protected $subheader = '';

/**
 * Returns the subheader
 *
 * @return string $subheader
 */
public function getSubheader()
{
    return $this->subheader;
}

/**
 * Sets the subheader
 *
 * @param string $subheader
 * @return void
 */
public function setSubheader($subheader)
{
    $this->subheader = $subheader;
}
}

setup.txt

config.tx_extbase {
objects {
    TYPO3\CMS\Core\Resource\Collection\StaticFileCollection {
        className = MyNamespace\MyExtension\Domain\Model\StaticFileCollection
    }
}
}

我错过了什么?

1 个答案:

答案 0 :(得分:0)

您的设置应如下所示:

config.tx_extbase{
    objects {
        TYPO3\CMS\Extbase\Domain\Model\Category.className = VENDOR\Extension\Domain\Model\Category
    }
    persistence.classes {
        VENDOR\Extension\Domain\Model\Category {
            mapping {
                tableName = sys_category
            }
        }
    }
}