TYPO3 несколько вложенных DatabaseQueryProcessor - PullRequest
0 голосов
/ 07 августа 2020

Я пытаюсь получить некоторые записи из пользовательских таблиц моего собственного расширения TYPO3.

У меня есть две таблицы: sectors и contacts.

Связь очень проста , один sector содержит несколько contacts.

Я пытаюсь создать страницу контактов, на которой я хотел бы показать contacts, сгруппированные по sectors.

Так что я бы хотел бы вложить QueryProcessors вместе:

    dataProcessing {
    10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
    10 {
        table = office_sectors 
        pidInList = root,-1
        recursive = 9999
        selectFields = office_sectors.*
        where = office_sectors.deleted = 0 AND office_sectors.hidden = 0
        where.inval = 1
        orderBy = office_sectors.name
        as = sectors            
        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
            10 {
                table = office_persons
                pidInList = root,-1
                recursive = 9999
                selectFields = office_persons.*
                where = office_persons.deleted = 0 AND office_persons.hidden = 0 AND office_sectors.RELATION_FIELD = office_persons.RELATION_FIELD
                where.inval = 1
                orderBy = office_persons.name
                as = persons            
            }         
        }             
    }       
}

Итак, я хотел бы получить список sectors объектов, содержащих все persons, принадлежащие каждому office. Я пытаюсь выбрать persons, отфильтровав их в предложении where, но я не знаю, как получить внешние поля вывода DatabaseQueryProcessor.

office_sectors.RELATION_FIELD = office_persons.RELATION_FIELD

1 Ответ

0 голосов
/ 04 сентября 2020

спасибо за предложение относительно DBAL, в любом случае я нашел решение с помощью typoscript, следующий код помогает. Пожалуйста, извините за "бесценную" ошибку, я изменил ее на intval.

    ##########################
dataProcessing {
    10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
    10 {
        table = office_sectors 
        pidInList = root,-1
        recursive = 9999
        selectFields = office_sectors .*
        where = office_sectors .deleted = 0 AND office_sectors .hidden = 0
        where.intval = 1
        orderBy = office_sectors .name
        as = sectors            
        dataProcessing {
            11 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
            11 {
                table = office_persons
                pidInList = root,-1
                recursive = 9999
                selectFields = office_persons.*
                where = office_persons.deleted = 0 AND office_persons.hidden = 0
                where {
                    data = field:uid
                    intval = 1
                    wrap = tt_content=|
                }                    
                orderBy = office_persons.name
                as = contacts            
            }         
        }             
    }       
}

Результирующий массив, напечатанный " {_все} "в шаблоне жидкости это:

sectors => array(5 items)
  0 => array(2 items)
     data => array(29 items)
     contacts => array(11 items)
        0 => array(1 item)
        1 => array(1 item)
        2 => array(1 item)
        3 => array(1 item)
        4 => array(1 item)
        5 => array(1 item)
        6 => array(1 item)
        7 => array(1 item)
        8 => array(1 item)
        9 => array(1 item)
        10 => array(1 item)
  1 => array(2 items)
  2 => array(2 items)
  3 => array(2 items)
  4 => array(2 items)

Я получаю вложенный массив, в котором каждый сектор содержит свои собственные контакты.

Спасибо !!

...