ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Dynamic folder name for asset field type

Open j3ll3yfi5h opened this issue 3 years ago • 5 comments

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.

j3ll3yfi5h avatar Jan 06 '22 19:01 j3ll3yfi5h

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.

jasonvarga avatar Jan 06 '22 19:01 jasonvarga

Good point. Currently I'm using read_only: true on the slug field to prevent this... đŸ¤”

j3ll3yfi5h avatar Jan 06 '22 19:01 j3ll3yfi5h

How about using folder: {id} instead?

j3ll3yfi5h avatar Jan 06 '22 19:01 j3ll3yfi5h

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?

j3ll3yfi5h avatar Oct 18 '22 12:10 j3ll3yfi5h

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

jasonvarga avatar Oct 18 '22 13:10 jasonvarga