I have a page content type with fields Title, Body and Blocks field collection with fields Title and URL.
It might be field collection, paragraphs or entity reference, it doesn't matter because all of these types require relationship in views in order to get its fields.
I need to generate a JSON output with views that look like this:
{
'title': 'This is my title',
'body': '<p>lorem ipsum dolor sit amet.</p>',
'blocks': [
{
'block_title': 'Block one',
'block_url': 'www.example.com'
},
{
'block_title': 'Block two',
'block_url': 'www.site.com'
},
]
}
What I managed to achieve so far, is this:
[
{
'title': 'This is my title',
'body': '<p>lorem ipsum dolor sit amet.</p>',
'block_title': 'Block one',
'block_url': 'www.example.com'
},
{
'title': 'This is my title',
'body': '<p>lorem ipsum dolor sit amet.</p>',
'block_title': 'Block two',
'block_url': 'www.site.com'
}
]
This is Drupal 8. Any suggestions?