title: TYPO3: Reading tt_address and print it sorted by sys_categories with fluid in own extbase extension
body: <p>I want to read the contents of tt_address and print them sorted by sys_categories in my own extbase/fluid extension.</p>
  
  <p>I mapped both tables in typoscript, created models, controllers and repositories for both and so I am able to print both tables complete without issues.</p>
  
  <p>However, I need to print only the adresses that match a certain category (depends on the page) but I can't get it to work.</p>
  
  <p>According to some research it should be posible to load them and access them in the fluid template like</p>
  
  <pre><code>    &lt;f:for each="{cats}" as="cat"&gt;
        &lt;f:for each="{cat.items}" as="adr"&gt;{adr}&lt;/f:for&gt;
      &lt;/f:for&gt;
  </code></pre>
  
  <p>But if I display them via the debug option there a no adresses attached to the cat array - no wonder that none are displayed.</p>
  
  <p>I created TCAs for both tables with only the M:M related column definition in it (categories for tt_address and items for sys_categories) and I included the following in the models:</p>
  
  <pre><code>    /**
       * Addresses
       *
       * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage&lt;\Vendor\Myext\Domain\Model\Address&gt;
       */
       protected $addresses;
  
       /**
        * Adds a Address
        *
        * @param \Vendor\Myext\Domain\Model\Address $address
        * @return void
        */
        public function addAddress(\Vendor\Myext\Address\Domain\Model\Address $address) {
         $this-&gt;addresses-&gt;attach($address);
        }
  
      /**
       * Removes a Address
       *
       * @param \Vendor\Myext\Domain\Model\Address $addressToRemove The Address to be removed
       * @return void
       */
       public function removeAddress(\Vendor\Myext\Domain\Model\Address $addressToRemove) {
        $this-&gt;addresses-&gt;detach($addressToRemove);
       }
  
      /**
       * Returns the Addresses
       *
       * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage&lt;\Vendor\Myext\Domain\Model\Address&gt; $addresses
       */
       public function getAddresses() {
        return $this-&gt;addresses;
       }
  
      /**
       * Sets the Addresses
       *
       * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage&lt;\Vendor\Myext\Domain\Model\Address&gt; $addresses
       * @return void
       */
       public function setAddresses(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $addresses) {
        $this-&gt;addresses = $addresses;
       }
  </code></pre>
  
  <p>and of course the other way round in the address-model.</p>
  
  <p>Where is the fault, what am I missing? Is it even possible to use M:M relations on mapped tables? Do I need a complete TCA? </p>
  
  <p>Please help I'm trying this desperately since one week. Each answer will be appreciated very much.</p>
  
  <p>Thanks in advance!</p>
  
  <p>PS: I want to use the "sys_category_record_mm"-relationship table of course.</p>