Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge fields and dataProcessing in JSON content #577

Open
dvdmlln opened this issue Apr 6, 2023 · 2 comments
Open

Merge fields and dataProcessing in JSON content #577

dvdmlln opened this issue Apr 6, 2023 · 2 comments

Comments

@dvdmlln
Copy link
Contributor

dvdmlln commented Apr 6, 2023

Hi,

currently it is not possible to define fields and dataProcessing because dataProcessing overwrites the whole content.
For example I'd like to define add a flexform to a text field.

The typoscript looks like this:

tt_content.text {
    fields {
        content {
            fields {
                flexform {
                    dataProcessing {
                        10 = FriendsOfTYPO3\Headless\DataProcessing\FlexFormProcessor
                        10 {
                            fieldName = pi_flexform
                            as = flexform
                        }
                    }
                }
            }
        }
    }
}

and the JSON output:

"content": {
  "header": "header",
  "subheader": "",
  "headerLayout": 0,
  "headerPosition": "",
  "headerLink": "",
  "bodytext": "bodytext"
  "flexform": {
    "additionalData": "data"
  }
}

So I moved the dataProcessing one level up like this so additionalData property moves on level up:

tt_content.text {
    fields {
        content {
            dataProcessing {
                10 = FriendsOfTYPO3\Headless\DataProcessing\FlexFormProcessor
                10 {
                    fieldName = pi_flexform
                    as = flexform
                }
            }
        }
    }
}

This leads to the dataProcessing overwriting the whole content:

"content": {
  "additionalData": "data"
}

Are there any reasons not to merge the fields and dataProcessing? Or did I miss something and this is already possible?
In line 131 in FriendsOfTYPO3\Headless\ContentObject\JsonContentObject the fields are always overwritten if dataProcessing exists.
I'd be happy to create a PR if this is something to be considered.
If there would be any side effects, maybe this could be allowed with an flag in the json content object?

Best regards
David

@twoldanski
Copy link
Collaborator

twoldanski commented May 8, 2023

Hi @dvdmlln, could you provide a PR?

@dvdmlln
Copy link
Contributor Author

dvdmlln commented May 9, 2023

#592

TypoScript would look like this:

tt_content.text {
    fields {
        content {
            merge = 1
            dataProcessing {
                10 = FriendsOfTYPO3\Headless\DataProcessing\FlexFormProcessor
                10 {
                    fieldName = pi_flexform
                    as = flexform
                }
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants