[TYPO3-mvc] n:1 get uid

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Sun Dec 14 16:56:23 CET 2014


Stange,

which T3 version are you using? Never tested this bidirectional relation
thing in 6.2, but I'm quite sure it didn't work for 4.6 without a proper
TCA config...

Cheers,
Till

On 12/14/2014 03:38 PM, Jacco van der Post wrote:
> Hi
>
> g4-lisz at tonarchiv.ch schreef op 13-12-2014 23:38:
>>
>> You need to replace the passthrough TCA with a config that references to
>> the right table, like:
>>
>>          'media' => array(
>>              'config' => array(
>>                  'type' => 'select',
>>                  'foreign_table' => 'tx_xx_domain_model_media',
>>                  'minitems' => 0,
>>                  'maxitems' => 1,
>>              ),
>>          ),
>>
>
> Thanks for your reaction, I solved it without changing the TCA. It is
> in fact easy, but not I could not find any examples, so it took me
> some time :
>
> In the model Comment.php I added :
>
>     /**
>      * Media
>      *
>      * @var \JaccovanderPost\Xxx\Domain\Model\Media
>      */
>     protected $media = NULL;
>
>
>     /**
>      * Returns the media
>      *
>      * @return \JaccovanderPost\Xxx\Domain\Model\Media $media
>      */
>     public function getMedia() {
>         return $this->media;
>     }
>
> Now in the Comment controller I have access to the parent object
> (after inserting the media repository) :
>
> $mediaItem = $comment->getMedia();
>
> And stuff like this
>
> $mediaItem->getUID();
> $mediaItem->getTitle();
>
> Etc.
>
>
> Would be nice if in the extension builder a getter and setter for
> access to a parent object would be automatically created for n:1
> relations.
>
>



More information about the TYPO3-project-typo3v4mvc mailing list