簡體   English   中英

TYPO3與自定義擴展中的fe_users的關系

[英]TYPO3 relation to fe_users in custom extension

我正在TYPO3 7.6中編寫一個extbase擴展來組織一個團隊。 分機密鑰是小隊。 每個團隊都屬於一個培訓師,該培訓師在fe_users表中有一條記錄。 因此,在我的團隊模型中,我與fe_users表有關系。 我從擴展程序構建器開始,然后按照以下網站上的說明調整了模型: https : //www.typo3.net/forum/thematik/zeige/thema/126982/TYPO3 Extbase fe_user UID在自己的模型中在后端關系工作正常,但在前端,我沒有在團隊視圖中列出培訓者。 什么東西少了?

我的代碼如下。

ext_tables.sql:

CREATE TABLE tx_squad_domain_model_team (
...
trainer int(11) unsigned DEFAULT '0',
...
)

TCA.php:

'trainer' => [
'label' => 'Trainer',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'fe_users',
'minitems' => 0,
'maxitems' => 1,
],
]

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
        }
      }
    }
  }
}

模型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;
    }
}

模板/團隊/ 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>
...

好吧,我找到了答案。 上面的設置正確。 但是正如我在ext_typoscript_setup.txt中設置的那樣

recordType = Tx_Squad_FrontendUser

我只能使用分配給recordType Tx_Squad_FrontendUser的fe_users。 在為fe_users分配正確的recordType之后,一切正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM