Ad

How Can I Use The Selected Category In A DatabaseQueryProcessor?

- 1 answer

I have a simple content element that I have added the categories field to. The user selects the parent category of their choice.

I want to use the DatabaseQueryProcessor to output a list of child categories to the one that was selected.

How do I format the where so that it gets categories with the parent of the chosen category?

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
    if.isTrue.field = categories
    table = sys_category
    selectFields = sys_category.*
    pidInList = {$categories}
    recursive = 999
    where = parent = ???
    as = categories
}
Ad

Answer

According to TSRef the database query processor makes use of the select function and its parameters. So something like this should be working - (not tested)

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
    if.isTrue.field = categories
    table = sys_category
    selectFields = sys_category.*
    pidInList = {$categories}
    recursive = 999
    join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
    where.dataWrap = sys_category_record_mm.uid_foreign={field:_ORIG_uid // field:uid} AND sys_category_record_mm.tablenames = 'mytable' AND sys_category_record_mm.fieldname = 'myfield'
    orderBy = sys_category_record_mm.sorting_foreign
    languageField = 0
    as = categories
}

https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Select.html#select

Ad
source: stackoverflow.com
Ad