TYPO3-Headless / headless

TYPO3 Headless JSON API providing content for PWA application (e.g. javaScript apps like nuxt-typo3)
https://t3headless.io
GNU General Public License v2.0
159 stars 60 forks source link

[FEATURE] Add categories DataProcessor #653

Open schloram opened 1 year ago

schloram commented 1 year ago

With this DataProcessor we can get rid of the chunky categories TypoScript. Plus this one is easier to re-use.

Additionally to that I also re-formatted the output of the categories since we always thought that the comma-separated list is unnecessary if the data is already structured. The frontend always had to split the string into an array themselves (we never could use the string as is). This is why I also changes the output from comma-separated list to an array of objects in the following format:

    "categories": [
      {
        "id": 3,
        "title": "Test Category 1"
      },
      {
        "id": 4,
        "title": "Test Category 2"
      },
      {
        "id": 7,
        "title": "Test Category 3"
      }
    ]

Example usage (get categories by relation record):

    categories = JSON
    categories {
        dataProcessing {
            10 = headless-categories
            10 {
                relation.fieldName = categories

                as = categories
            }
        }
    }

Example usage (get categories by comma-separated-list of category ids):

    categories = JSON
    categories {
        dataProcessing {
            10 = headless-categories
            10 {
                categoryIdList = 1,3,5

                as = categories
            }
        }
    }
lukaszuznanski commented 1 year ago

Hi, please fix codestyle and tests and we can merge it then :)

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 7250772858


Totals Coverage Status
Change from base Build 7196892465: 0.0%
Covered Lines: 835
Relevant Lines: 1300

💛 - Coveralls