[英]TYPO3 relation to fe_users in custom extension
I am writing an extbase extension in TYPO3 7.6 to organize a team. 我正在TYPO3 7.6中编写一个extbase扩展来组织一个团队。 The extension key is squad.
分机密钥是小队。 Every team belongs to a trainer which has a record in the fe_users table.
每个团队都属于一个培训师,该培训师在fe_users表中有一条记录。 So in my team model I have a relation to the fe_users table.
因此,在我的团队模型中,我与fe_users表有关系。 I started with the extension builder and afterwards adjusted my model following the instructions on these sites: https://www.typo3.net/forum/thematik/zeige/thema/126982/ and TYPO3 Extbase fe_user UID in own model In the backend the relation works fine, but in the frontend I don't get the trainer listed in the team view.
我从扩展程序构建器开始,然后按照以下网站上的说明调整了模型: https : //www.typo3.net/forum/thematik/zeige/thema/126982/和TYPO3 Extbase fe_user UID在自己的模型中在后端关系工作正常,但在前端,我没有在团队视图中列出培训者。 What is missing?
什么东西少了?
My code is as following. 我的代码如下。
ext_tables.sql: ext_tables.sql:
CREATE TABLE tx_squad_domain_model_team (
...
trainer int(11) unsigned DEFAULT '0',
...
)
TCA.php: TCA.php:
'trainer' => [
'label' => 'Trainer',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'fe_users',
'minitems' => 0,
'maxitems' => 1,
],
]
ext_typoscript_setup.txt ext_typoscript_setup.txt
config.tx_extbase {
persistence {
classes {
TYPO3\CMS\Extbase\Domain\Model\FrontendUser {
subclasses {
Tx_Squad_FrontendUser = VENDOR\Squad\Domain\Model\FrontendUser
}
}
VENDOR\Squad\Domain\Model\FrontendUser {
mapping {
tableName = fe_users
recordType = Tx_Squad_FrontendUser
}
}
}
}
}
Model Team.php 模型Team.php
class Team extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* trainer
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
*/
protected $trainer;
/**
* Returns the trainer
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $trainer
*/
public function getTrainer()
{
return $this->trainer;
}
/**
* Sets the trainer
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $trainer
* @return void
*/
public function setTrainer(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $trainer)
{
$this->trainer = $trainer;
}
}
Templates/Team/List.html 模板/团队/ List.html
...
<f:for each="{teams}" as="team">
<f:debug>{team}</f:debug>
<tr>
<td>{team.trainer}</td>
<td><f:link.action action="show" arguments="{team: team}"> {team.name}</f:link.action></td>
<td><f:link.action action="show" arguments="{team: team}"> {team.ccemail}</f:link.action></td>
<td><f:link.action action="edit" arguments="{team: team}">Edit</f:link.action></td>
<td><f:link.action action="delete" arguments="{team: team}">Delete</f:link.action></td>
</tr>
</f:for>
...
Okay, I found the answer. 好吧,我找到了答案。 The setup above is correct.
上面的设置正确。 But as I set in ext_typoscript_setup.txt
但是正如我在ext_typoscript_setup.txt中设置的那样
recordType = Tx_Squad_FrontendUser
I could only use fe_users who were assigned to the recordType Tx_Squad_FrontendUser. 我只能使用分配给recordType Tx_Squad_FrontendUser的fe_users。 After assigning the correct recordType to the fe_users everything worked fine.
在为fe_users分配正确的recordType之后,一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.