FriendsOfTYPO3 / extension_builder

TYPO3 extension to kickstart and maintain TYPO3 extensions
https://docs.typo3.org/p/friendsoftypo3/extension-builder/11.0/en-us/
GNU General Public License v2.0
113 stars 80 forks source link

🐛 [BUG] Enable categorization - Missing categories in frontend #196

Open ste101 opened 5 years ago

ste101 commented 5 years ago

With the option 'Enable categorization?' I can use categories in the backend but I am not able to use these categories in fluid out of the box.

What is missing?

nicodh commented 5 years ago

A detailed description in your bug report... "I am not able to use these categories" is not a bug

ste101 commented 5 years ago

Sorry for the short description. As I wrote it is not possible to use categories in the frontend out of the box.

It would be neccesarry to add some code if you have checked the option 'Enable categorization' like this:

diff -ru test.orig/Classes/Controller/TestController.php test/Classes/Controller/TestController.php
--- test.orig/Classes/Controller/TestController.php 2019-04-20 22:16:58.000000000 +0200
+++ test/Classes/Controller/TestController.php  2019-04-20 22:36:39.000000000 +0200
@@ -18,6 +18,14 @@
 class TestController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
 {
     /**
+     * CategoryRepository
+     *
+     * @var \TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository
+     * @inject
+     */
+    protected $categoryRepository = null;
+
+    /**
      * testRepository
      *
      * @var \SB\Test\Domain\Repository\TestRepository
diff -ru test.orig/Classes/Domain/Model/Test.php test/Classes/Domain/Model/Test.php
--- test.orig/Classes/Domain/Model/Test.php 2019-04-20 22:16:58.000000000 +0200
+++ test/Classes/Domain/Model/Test.php  2019-04-20 22:37:32.000000000 +0200
@@ -18,6 +18,14 @@
 class Test extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
 {
     /**
+     * categories
+     *
+     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category>
+     * @lazy
+     */
+    protected $categories = null;
+
+    /**
      * test
      *
      * @var string
@@ -25,6 +33,27 @@
     protected $test = '';

     /**
+     * Get categories
+     *
+     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category>
+     */
+    public function getCategories()
+    {
+        return $this->categories;
+    }
+
+    /**
+     * Set categories
+     *
+     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $categories
+     * @return void
+     */
+    public function setCategories($categories)
+    {
+        $this->categories = $categories;
+    }
+
+    /**

I tried to make a patch but I wasn't able to find the right places.

I'm not shure if it is neccesary to add a class mapping in ext_typoscript_setup.txt like this:

config.tx_extbase {
    persistence {
        classes {

            SAM\FtsProducts\Domain\Model\Category {
                mapping {
                    recordType = 0
                    tableName = sys_category
                }
            }

        }
    }
}