Relate default asset location based on site #12231
-
Hi there, I'm unsure if my issue is just niche to my use of Craft or if I've perhaps incorrectly setup Craft. I work for a company who develop tabletop games, and we use Craft to host the unit cards that frequently get added and amended with rule changes. Unit Cards are their own Structure entries, and they have various fields added to them for organisation and sorting etc. The problem is we have three different game systems that each use Unit Cards, but the default upload path is always fixed to one of the volumes rather than related to the site that is entry the currently being created/edited in. For example, a Unit Card Main Card asset is being edited in Mythos, rather than the default upload position being [Mythos Volume]/unit-cards/main-card, it's always just [Global]/unit-cards/main-card. Unfortunately, those uploading on the backend aren't paying attention to the filesystem and just uploading in the default location, meaning someone is consistently going in and moving files around (which in turn is causing grief when they link to a moved asset in the filesystem resulting in a 404). I'm aware this is probably quite a large architectural shift, in coupling volumes to sites, and adding a drop-down option for sites rather than volumes in the default asset path, but is this a discussed possibility? If not, I'll assume I'll have to create three types of Unit Card structures based on the game systems which seems redundant but in a perfect world I wouldn't have to worry about user issues! Unless there is potentially another better way that I have overlooked, such as recreating the filesystem. Any questions feel free to ask. Kind regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
One option is, rather than giving each site its own volume, you could have them all share the same volume and give the volume site-specific subfolders. Then in your Assets field, you can enable the “Restrict assets to a single location” setting, and set the location to begin with If you’re using Craft 4, you can do this without sacrificing nested subfolders, thanks to the new “Allow subfolders” setting (#9070). |
Beta Was this translation helpful? Give feedback.
One option is, rather than giving each site its own volume, you could have them all share the same volume and give the volume site-specific subfolders. Then in your Assets field, you can enable the “Restrict assets to a single location” setting, and set the location to begin with
{site.handle}/...
.If you’re using Craft 4, you can do this without sacrificing nested subfolders, thanks to the new “Allow subfolders” setting (#9070).