Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic folder name for asset field type #725

Closed
j3ll3yfi5h opened this issue Jan 6, 2022 · 5 comments · Fixed by statamic/cms#10808
Closed

Dynamic folder name for asset field type #725

j3ll3yfi5h opened this issue Jan 6, 2022 · 5 comments · Fixed by statamic/cms#10808

Comments

@j3ll3yfi5h
Copy link

It would be nice, if we could use a dynamic folder name with the asset field type:
Maybe something like folder: {slug}, to keep the asset container tidy and e.g. assets/entries together.

@jasonvarga
Copy link
Member

It's probably more complicated than it sounds. If you change the slug of the entry, all the assets would need to be renamed too.

@j3ll3yfi5h
Copy link
Author

Good point. Currently I'm using read_only: true on the slug field to prevent this... 🤔

@j3ll3yfi5h
Copy link
Author

How about using folder: {id} instead?

@j3ll3yfi5h
Copy link
Author

j3ll3yfi5h commented Oct 18, 2022

Hi @jasonvarga! I'm trying to implement this requested behavior with an EntryCreated (create folder structure) and an EntryBlueprintFound (update folder paths) event listener. I have the problem, that with the first opening of the publishform of an entry, there isn't a uuid until its first save (and there isn't a folder with the same uuid).

Any idea, how I could trigger uuid generation earlier, right before the EntryBlueprintFound listener is triggered? Or how I could set the uuid manually and pass it to the EntrySaving listener?

@jasonvarga
Copy link
Member

Not sure. The ID is generated when the entry actually gets created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants