relation - TYPO3: Reading tt_address and print it sorted by sys_categories with fluid in own extbase extension -
i want read contents of tt_address , print them sorted sys_categories in own extbase/fluid extension.
i mapped both tables in typoscript, created models, controllers , repositories both , able print both tables complete without issues.
however, need print adresses match category (depends on page) can't work.
according research should posible load them , access them in fluid template like
<f:for each="{cats}" as="cat"> <f:for each="{cat.items}" as="adr">{adr}</f:for> </f:for>
but if display them via debug option there no adresses attached cat array - no wonder none displayed.
i created tcas both tables m:m related column definition in (categories tt_address , items sys_categories) , included following in models:
/** * addresses * * @var \typo3\cms\extbase\persistence\objectstorage<\vendor\myext\domain\model\address> */ protected $addresses; /** * adds address * * @param \vendor\myext\domain\model\address $address * @return void */ public function addaddress(\vendor\myext\address\domain\model\address $address) { $this->addresses->attach($address); } /** * removes address * * @param \vendor\myext\domain\model\address $addresstoremove address removed * @return void */ public function removeaddress(\vendor\myext\domain\model\address $addresstoremove) { $this->addresses->detach($addresstoremove); } /** * returns addresses * * @return \typo3\cms\extbase\persistence\objectstorage<\vendor\myext\domain\model\address> $addresses */ public function getaddresses() { return $this->addresses; } /** * sets addresses * * @param \typo3\cms\extbase\persistence\objectstorage<\vendor\myext\domain\model\address> $addresses * @return void */ public function setaddresses(\typo3\cms\extbase\persistence\objectstorage $addresses) { $this->addresses = $addresses; }
and of course other way round in address-model.
where fault, missing? possible use m:m relations on mapped tables? need complete tca?
please i'm trying desperately since 1 week. each answer appreciated much.
thanks in advance!
ps: want use "sys_category_record_mm"-relationship table of course.
did add categories tt_address table makecategorizable()
?
this add correct tca on tt_address don't have worry mm raltaions. can fetch needed records based on parameters . in case, category of page. , can create category collections push view .
all explained in here : https://docs.typo3.org/typo3cms/coreapireference/apioverview/categories/index.html
Comments
Post a Comment