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

Content elements with empty string in JsonContentContentObject->groupContentElementsByColPos() #710

Closed twaurisch closed 5 months ago

twaurisch commented 7 months ago

Depending on the TypoScript configuration it is possible that empty strings arrive in JsonContentContentObject->groupContentElementsByColPos().

It would be nice to check for an empty string in parallel to the 'Oops, an error occurred!' check and continue the same way.

Example TypoScript for the described case:

tt_content.flat_shortcut >
tt_content.flat_shortcut = COA
tt_content.flat_shortcut {
    5 = LOAD_REGISTER
    5 {
        shortcutColPos = TEXT
        shortcutColPos {
            field = colPos
        }
    }
    10 = RECORDS
    10 {
        source.field = records
        tables = {$styles.content.shortcut.tables}
        conf {
            {$styles.content.shortcut.tables}.stdWrap.wrap = ###SUBBREAK###|
        }
        stdWrap {
            replacement {
                5 = LOAD_REGISTER
                # Replace the colPos of the child element with the colPos of the shortcut
                10 {
                    search = #("colPos":[0-9]+)#i
                    replace {
                        stdWrap {
                            cObject = TEXT
                            cObject {
                                value = "colPos":{register:shortcutColPos}
                                insertData = 1
                            }
                        }
                    }
                    useRegExp = 1
                }
            }

        }
    }
    stdWrap {
        wrap = |
        split {
            token = ###SUBBREAK###
            cObjNum = 1 |*| 2 |*| 3
            1 {
                current = 1
                stdWrap.wrap = |
            }

            2 {
                current = 1
                stdWrap.wrap = |###BREAK###
            }

            3 {
                current = 1
                stdWrap.wrap = |
            }
        }
    }
}

The current workaround is to add ifEmpty = Oops, an error occurred!