TYPO3 individual query filter by another table

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 03:59:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!