I have domains such as uk.example.com and us.example.com. If users on these domains upload an image using Imagefield, I would like the image to be stored in /files/us and files/uk respectively. I have attached a patch providing a token for this.
In my patch, the tokens are called [domain-prefix] and [domain-prefix-raw], which I just realised might cause unnecessary confusion with the Domain Prefix module. However, Im a bit stumped as to what the first bit of the subdomain is called (its also way past my bedtime at the moment). If an alternative name can be suggested, Ill submit another patch.
Comments
Comment #1
agentrickardHow about [domain-subdomain], with documentation. It would especially need a note that it really only works with *.example.com formats.
Comment #2
nirbhasa commentedI changed the token names as per your suggestion, and added an extra note to the token description.
Comment #3
agentrickardLooks good to me.
Comment #4
agentrickardThis makes sense for image and file fields, less useful with PathAuto.
I altered the code to ensure that the domain string is at least three elements. If not, then you are on the primary domain and the prefix 'www' is used by default. If the primary domain is something like uk.example.com, then 'uk' is returned.
Committed to HEAD!