1

Is there a way to specify locale-specific asset paths so that uploaded images are only viewable on a per-locale basis, or would I have to set distinct assets (and ergo distinct fields) for each locale I wanted to provide uploads for?

For example, if am using locales to set a site A and a site B, can I have the same asset field declared but reference a different set of assets if they are logged in to site A rather than site B?

I've done some digging and testing and it looks like I can specify a locale in the general config, eg if following are declared in config (with LOCALE being defined in index.php based on locale :

'asset_path' => $_SERVER['DOCUMENT_ROOT'] . '/resources/' . LOCALE . '/',
'asset_url' => 'http://' . $_SERVER['SERVER_NAME'] . '/resources/' . LOCALE . '/',

However, despite this uploading files correctly (depending on context) these are still visible in the admin/control panel from other locales.

Is this at all possible? Working on a site with 6 locales that needs to keep assets separate and would rather not have to set multiple asset paths/file destinations and ergo multiple field types to achieve this.

Ta,

Cole

1 Answer 1

1

I am not convienced that using Craft localization feature is a (good) solution to do multi-sites. But regarding you problem, did you try to add craft.local as part of a Dynamic Subfolder Paths configuration. That could work for you.

4
  • Thanks Carl I've tried this approach which works but the main problem is that assets for other locales remain visible in the assets modal, which we're trying to avoid Commented Oct 30, 2015 at 12:28
  • Did you have "Restrict uploads to a single folder?" set to true?
    – carlcs
    Commented Oct 30, 2015 at 12:31
  • yes, but even removing shows everything contained within that folder, rather than anything specific to that locale Commented Oct 30, 2015 at 12:51
  • 1
    You could modify that plugin for you needs: Asset Subfolder Access. Other than that I've no idea what you could do. If it was me, I wouldn't mis-use the localization feature to begin with.
    – carlcs
    Commented Oct 30, 2015 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.