0

I am writing an extbase extension in TYPO3 7.6 to organize a team. The extension key is squad. Every team belongs to a trainer which has a record in the fe_users table. So in my team model I have a relation to the fe_users table. 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. What is missing?

My code is as following.

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

Model 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

...
<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>
...
2
  • Can you add the Fluid template as well? Commented Sep 27, 2018 at 8:42
  • I added the fluid template now. If I debug team I get me NULL for the trainer even though a trainer is shown in the backend. Commented Sep 28, 2018 at 7:01

1 Answer 1

1

Okay, I found the answer. The setup above is correct. But as I set in ext_typoscript_setup.txt

recordType = Tx_Squad_FrontendUser

I could only use fe_users who were assigned to the recordType Tx_Squad_FrontendUser. After assigning the correct recordType to the fe_users everything worked fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.