问题
I have TYPO3 version 7.6.18, and want get data with filtering by field on another relation table.
class PhotoRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
public function getFiltered($offset = 0, $limit = 5){
$query = $this->createQuery();
$query->matching($query->in('cruserId.gender', 3));
return $query->execute();
}
}
Model:
class Photo extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* CruserId
*
* @var \Fhk\Feusersplus\Domain\Model\User>
*/
protected $cruserId;
/**
* Returns the cruserId
*
* @return \Fhk\Feusersplus\Domain\Model\User> $cruserId
*/
public function getCruserId()
{
return $this->cruserId;
}
/**
* Sets the cruserId
*
* @return void
*/
public function setCruserId($cruserId)
{
$this->cruserId = $cruserId;
}
}
And my TCA:
'cruser_id' => [
'exclude' => 1,
'label' => 'LLL:EXT:fefiles/Resources/Private/Language/locallang_db.xlf:tx_fefiles_domain_model_photo.cruser_id',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'fe_users',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
]
],
That not works. I get error. I don't know what is this error because it not put in error log. I think may be I should write relation in ext_typoscript_setup.txt or somewhere? I think I should make reference somewhere, but I don't know
回答1:
There should be a clear error message.
In any case the > in \Fhk\Feusersplus\Domain\Model\User> is wrong and must be removed. Please try that first.
回答2:
Problem was in wrong TCA. The right TCA is :
'cruser_id' => [
'exclude' => 1,
'label' => 'LLL:EXT:fefiles/Resources/Private/Language/locallang_db.xlf:tx_fefiles_domain_model_photo.cruser_id',
'config' => [
'type' => 'group',
'foreign_table' => 'fe_users',
'minitems' => 0,
'maxitems' => 1,
'appearance' => [
'collapseAll' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
],
]
],
来源:https://stackoverflow.com/questions/44941882/typo3-individual-query-filter-by-another-table