Hello, everyone! I have a problem when copying resources with a MIGX tv field.
I needed to implement multi-uploading of photos in my resources, and I successfully did it. Steps of my actions:
- I created a MIGX called resourcealbum.
- I created a new “Media Source” called “ResourceMediaPath”.
- I created a TV field called “resourcealbum” and selected the source “ResourceMediaPath”, and also provided access to the necessary templates.
Now, when I create a resource, I can upload many photos in a multi-upload, because a folder with the resource id is automatically created at the path “assets/AdditionalPhotos/1” where “1” corresponds to the ID of the created resource.
BUT I’M FACING ONE PROBLEM!
When I try to duplicate this resource that already contains these additional photos, the new resource contains the paths of the previous resource and for some reason the photos are not copied to the server((
I’m from Ukraine, I tried to find an answer on our forums, but didn’t find anything, as we have a very small MODX community. I will be very grateful for your help if you can find a way and tell me how to make sure that when copying one resource, all the files that were uploaded to it (including photos) are also copied and the paths are correct.
I’ve attached a link to Google Drive (there are screenshots and the migx json file).
https://drive.google.com/drive/folders/12McbbBJd-wUH0HWDyAYX5TcWnlGgwnfU?usp=sharing
I don’t know what to do anymore((
Maybe need to write some kind of plugin, something like this?
<?php
switch ($modx->event->name) {
case 'OnResourceDuplicate':
// There must be some code here that should help me fix copying my resources along with the file to the new resource id folder...
break;
}
return;
But I do not know how to write such a plugin( I only know that there should be a very simple solution to copy resources, also copied files to the new paths(