We have then installed nova-flexible-content and added a couple of flexible layouts:
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
Text::make('Subtitle')
->sortable()
->rules('required', 'max:255'),
Flexible::make('Content')
->addLayout('Simple content section', 'wysiwyg', [
Text::make('Title'),
Markdown::make('Content')
])
->addLayout('Video section', 'video', [
Text::make('Title'),
Text::make('Video ID (YouTube)', 'video'),
Text::make('Video Caption', 'caption')
]),
];
}
We cannot figure out how to then access the flexible content, all we can get is the json. We have read the documentation about casting using the flexible() helper but cannot figure it out. Here is what we currently have:
<p>Edited on <time datetime="2022-01-19T16:38:37+00:00">Jan 19, 2022</time></p>
<p>All you need to know!</p>
<p>[{"key":"hMkhMH5bJKdC8tpO","layout":"wysiwyg","attributes":{"title":"Sample Title","content":"Lorem ipsum"}},{"key":"9eoUojlRf4ylGGkN","layout":"video","attributes":{"title":"Video Title","video":"0984343","caption":"Sample caption"}}]</p>
Any help or pointers would be massively appreciated.
Hi there,
We have installed Nova Page and have set up an example page with a view that outputs the data as expected.
We have then installed nova-flexible-content and added a couple of flexible layouts:
We cannot figure out how to then access the flexible content, all we can get is the json. We have read the documentation about casting using the flexible() helper but cannot figure it out. Here is what we currently have:
Output:
About Us
Any help or pointers would be massively appreciated.
Thank you.