b13 / container

A TYPO3 Extension for creating custom nested content elements
GNU General Public License v2.0
168 stars 67 forks source link

Get FlexForm config from child element #146

Closed the-robman closed 3 years ago

the-robman commented 3 years ago

Hello guys,

your container extension is awesom! That makes the content elements creating much easier.

I tryed to get the flexform config from a child element inside a container, with this:

tt_content.container_btcards < lib.contentElement
tt_content.container_btcards {
    templateName = BtCards
    layoutRootPaths.10 = EXT:path/to/Layouts/
    templateRootPaths.10 = EXT:path/to/Templates/
    partialRootPaths.10 = EXT:path/to/Partials/

    // works perfect and deliver the flexform config
    dataProcessing.10 = My\Custom\DataProcessing\FlexFormProcessor
    dataProcessing.10 {
        fieldName = pi_flexform
        as = flexform
    }
    dataProcessing.221 = B13\Container\DataProcessing\ContainerProcessor
    dataProcessing.221 {
            colPos = 221
            as = btcards
            // no flexform config here
            dataProcessing.10 = My\Custom\DataProcessing\FlexFormProcessor
            dataProcessing.10 {
                fieldName = pi_flexform
                as = flexform_from_child
            }
            // images from child works too
            dataProcessing.20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
            dataProcessing.20 {
                references.table = tt_content
                references.fieldName = image
                as = images
            }
        }
    }
}

The "My\Custom\DataProcessing\FlexFormProcessor" is this one. The first flexform dataprocessing for the parent container works, the second inside not.

Have you any idea, why the second dataprocess quit his work? Thank you for this great extension!

Greetings Robert

erredeco commented 3 years ago

I am interested, too... got the same issue

the-robman commented 3 years ago

Thanks for the fast reply. I tested the bugfix from here. The second dataProcessing result (dataProcessing.221.dataProcessing.20) for the image(s) also disappeared now.

Environment: DDEV 1.16.7, TYPO3 10.4.14, PHP 7.4.3 Happy easter days for you!

achimfritz commented 3 years ago

@the-robman Thanks for testing and reporting. Do the first dataProcessing for the child now work for you? can you test this commit? https://github.com/b13/container/commit/40ae5f9d6d0978d584ef72e7a4c8186cfc9b56a2

the-robman commented 3 years ago

Hi Achim, everything works fine now. The dataProcessor for the parent flexform and flexform + image(s) from child(s). Thanks for help and fixing the problem!

achimfritz commented 3 years ago

must be merged

the-robman commented 3 years ago

I found another problem today. If I have a accordion with child elements inside and put the accordion inside a 2-cols container, the dataProcess for the "grandParentFromChild" is empty. Here's a code example:

tt_content.container_accordion < lib.contentElement
tt_content.container_accordion {
    dataProcessing.211 = B13\Container\DataProcessing\ContainerProcessor
    dataProcessing.211 {

        colPos = 211
        as = accordion

        // flexform still work
        dataProcessing.10 = My\Custom\DataProcessing\FlexFormProcessor

        // get files from childs too
        dataProcessing.20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor

        // get data from parent (accordion): OK
        dataProcessing.30 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
        dataProcessing.30 {
            if.isTrue.field = tx_container_parent
            table = tt_content
            where = tt_content.CType='container_accordion'
            uidInList.field = tx_container_parent
            as = dataFromParent

            // get data from parent (2-cols container) of parent (accordion):
            // is empty
            dataProcessing.40 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
            dataProcessing.40 {
                if.isTrue.field = tx_container_parent
                table = tt_content
                where = tt_content.CType='container_accordion_in_2columns'
                uidInList.field = tx_container_parent
                as = grandParentFromChild
            }
        }
    }
}
achimfritz commented 3 years ago

@the-robman hm, for me this looks not like a bug of the container dataProcessor, whatever, can you please raise a new issue for this, and provide your Container Configs

the-robman commented 3 years ago

Please forget the last comment :-) A better solution comes with fluid foreach, if (parent), then queries. To much dataProcessor nesting makes the logic unnecessary complicated.

dmitryd commented 3 years ago

The problem must be in the flexform data processor. We have my own and the following config works fine for me:

  DownloadList = < lib.contentElement
  DownloadList {
    templateName = DownloadList

    dataProcessing {
      10 = Snowflake\Template\DataProcessing\FlexformDataProcessor
      10 {
        dataProcessing {
          10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
          10 {
            references.fieldName = files1
            as = files1
          }

          20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
          20 {
            references.fieldName = files2
            as = files2
          }

          30 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
          30 {
            references.fieldName = files3
            as = files3
          }
        }
      }
    }
  }

I have all three working:

dump

achimfritz commented 3 years ago

@dmitryd you are right, but the flexform data processor above works for "normal" Content-Elements as DataProcessor, i think it should also work for Container Content-Elements

dmitryd commented 3 years ago

@achimfritz I have it for containers too (it adds flexform fields) but I did not try with nested. I do not see why it should not work though because subprocessors will be called from my processor. Here is the TS:

  AccordeonContainer = < lib.contentElement
  AccordeonContainer {
    templateName = AccordeonContainer
    dataProcessing {
      10 = B13\Container\DataProcessing\ContainerProcessor
      20 = Snowflake\Template\DataProcessing\FlexformDataProcessor
    }
  }

There I got the full data record and add flexform fields. My procesor does not care if it is called on container or not.

achimfritz commented 3 years ago

i have thiink about it, and my result for the FlexFormProcessor is:

do not access the pi_flexform from $processedData['data'][$fieldName] but access the field from $cObj->data[$fieldName]

https://github.com/benjaminkott/bootstrap_package/blob/master/Classes/DataProcessing/FlexFormProcessor.php#L63 https://github.com/benjaminkott/bootstrap_package/blob/master/Classes/DataProcessing/FlexFormProcessor.php#L68