Just making an issue here to brainstorm.
I was playing around with the best way to approach this and was first considering how we'd want it to look from the template side.
Option 1:
Make the fields param a hash.
true would indicate just returning the value.
- a hash would indicate this field had nested data (e.g.
matrix or entires), and which fields or columns to get.
- a
true instead of a map on an entries field could return an array of IDs.
- a
true instead of a map on an matrix field could return a hash of every column and it's value.
{{ craft.entries.section('news').find() | prune({
'id': true
'title': true,
'myEntriesField': {
'id': true,
'otherField': true,
'myNestedMatrixField': true,
},
'myMatrixField': {
'myCol': true,
'myEntriesCol': {
'id': true,
'title': true,
}
},
'myOtherEntriesField': true
}) | json_encode() | raw }}
Option 2:
Add a 3rd mappings param, with the keys of the field and the value of the fields/columns you want.
{{ craft.entries.section('news').find() | prune(
['id', 'title', 'myEntriesField', 'myMatrixField', 'myOtherEntriesField'], {
'myEntriesField': ['id', 'otherField', 'myNestedMatrixField'],
'myMatrixField': ['myCol', 'myEntriesCol'],
'myEntriesCol': ['id', 'title'],
}) | json_encode() | raw }}
Just making an issue here to brainstorm.
I was playing around with the best way to approach this and was first considering how we'd want it to look from the template side.
Option 1:
Make the fields param a hash.
truewould indicate just returning the value.matrixorentires), and which fields or columns to get.trueinstead of a map on anentriesfield could return an array of IDs.trueinstead of a map on anmatrixfield could return a hash of every column and it's value.Option 2:
Add a 3rd
mappingsparam, with the keys of the field and the value of the fields/columns you want.