You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spatie's MediaLibrary\HasMedia\HasMedia interface & MediaLibrary\HasMedia\HasMediaTrait should both be implemented on the resource model (not on the Flexible layout!) ;
Is there any idea how to get this working?
Would be nice to define the media collections in the template files and use advanced-nova-media-library field 🤔
The problem here is that Spatie's library requires a model in order to link the media to it. By default, this package does not use models (data is stored in JSON files). Therefore, you should switch to database storage. This will however probably not work with the current version of nova-flexible-content, since the model is difficult to fetch from inside a Flexible content.
I'm working on a fix for a similar issue (the one you linked in your post) as we speak, I'll try to find a solution that also fixes this one.
So with the still missing PR from advanced-nova-media-library I got it working with nova-flexible-content but with some limitations...
Adding the same Layout multiple times overwrites the images (related to this issue I think.)
Defining single file collections won't work (also related to this issue
One more issue (not related to nova-flexible-content) is adding Images to the page directly.
Defining advanced-nova-medialibrary fields on the Template worked for me (inspired by your trait in nova-flexible-content) by adding the following code to the template:
Make the template implement use Spatie\MediaLibrary\HasMedia\HasMedia; and adding the trait with use Spatie\MediaLibrary\HasMedia\HasMediaTrait;.
Activity
toonvandenbos commentedon Aug 23, 2019
Hi @OliverZiegler,
The problem here is that Spatie's library requires a model in order to link the media to it. By default, this package does not use models (data is stored in JSON files). Therefore, you should switch to database storage. This will however probably not work with the current version of nova-flexible-content, since the model is difficult to fetch from inside a Flexible content.
I'm working on a fix for a similar issue (the one you linked in your post) as we speak, I'll try to find a solution that also fixes this one.
Added Model for database source. Added Template::getOriginal method f…
toonvandenbos commentedon Aug 23, 2019
Hi @OliverZiegler,
Could you update both packages (using
dev-masterfor nova-page) and tell me if this issue is fixed?Here's how I got it working (you should probably re-publish the package's configuration file):
sources.database.modelto your newPagemodel (or whatever you named it).OliverZiegler commentedon Aug 26, 2019
Thanks for the fast response!!
So with the still missing PR from advanced-nova-media-library I got it working with nova-flexible-content but with some limitations...
One more issue (not related to nova-flexible-content) is adding Images to the page directly.
Defining advanced-nova-medialibrary fields on the Template worked for me (inspired by your trait in nova-flexible-content) by adding the following code to the template:
Make the template implement
use Spatie\MediaLibrary\HasMedia\HasMedia;and adding the trait withuse Spatie\MediaLibrary\HasMedia\HasMediaTrait;.Furthermore adding:
GarethSomers commentedon Sep 3, 2019
Hey guys,
When running:
whitecube/nova-page:dev-masterwhitecube/nova-flexible-content@cfd8719https://github.com/whitecube/nova-flexible-content/pull/71Pressing save won't do anything 😕
Update
My fault, ignore me :)
amidesfahani commentedon Oct 11, 2020
does it world?