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
{{ message }}
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
I'm using the Cake4 branch to upload multiple images. I am using the afterPath event listener to customise the upload path so that my uploads are stored at:
articles\2020-07-04-104002\file_1.jpg
In order that the path does't include the folder "files" (my upload field as per the config) I had to do the following: - is this the best approach?
$path->setField(null);
Further, Is it possible to use the slug of the article in place of the data stamp, for example:
articles\my-article-title\file_1.jpg
I have looked into the createPath function of ProfferBehaviour but can't see how I can pass the parent entity (Articles) into the event where I'd need it to construct the path.
If this requires some custom development I would be happy to get involved and create a PR but I don't want to re-invent the wheel.
Thanks!
The text was updated successfully, but these errors were encountered:
Well the path class constructor takes an entity, so you could pass some data into the path clas instance that way if you wanted to interpolate something into the path.
Thanks - when you mention the path class are you referring to: ProfferPath.php. If so when I debug the $entity in the constructor the entity in this case is the image itself - since the Proffer behaviour is attached to a hasMany relationship - ArticleImages. Since articles hasMany ArticleImages I need access to the Article entity here (for the article name).
I'm using the Cake4 branch to upload multiple images. I am using the afterPath event listener to customise the upload path so that my uploads are stored at:
articles\2020-07-04-104002\file_1.jpg
In order that the path does't include the folder "files" (my upload field as per the config) I had to do the following: - is this the best approach?
$path->setField(null);
Further, Is it possible to use the slug of the article in place of the data stamp, for example:
articles\my-article-title\file_1.jpg
I have looked into the createPath function of ProfferBehaviour but can't see how I can pass the parent entity (Articles) into the event where I'd need it to construct the path.
If this requires some custom development I would be happy to get involved and create a PR but I don't want to re-invent the wheel.
Thanks!
The text was updated successfully, but these errors were encountered: