0

I have a multilingual entry setup using different sites for each language. I want my assets sorted by slug, but since the slugs are different in each language, all assets are saved three times. My idea was to sort them not just by slug, but by the slug of their primary site sibling. So that all the assets from the same entry (no matter if they are uploaded on the DE, EN or FR site) are being saved in one folder using the slug of the EN site. Is this even possible?

2 Answers 2

2

This might not be a full blown solution but given the current entry, you can get the corresponding entry of another site by using

{% set otherLocaleEntry = craft.entries.siteId(lang.id).id(entry.id).one() %}

As you can see you only need the id of the desired language's site and the entry id. You then have the entry of the other language and you can get its slug.

1
  • Thanks Mike! Your answer pushed me into the right direction. I added a separate answer in which i edited your code accordingly and also prepared it to use inside a matrix field.
    – Sandro
    Sep 26 at 10:07
1

Thanks to MisterMike's answer I was able to get what I want. My asset location path is now set to {{craft.entries.siteId(1).id(id).one().slug}}. The siteId 1 is the ID of the site from which i want to use the slug.

To use this location path inside of a matrix/neo field, you would have to add owner like this: {{craft.entries.siteId(1).id(owner.id).one().slug}}.

With this location path, all assets from all languages are being saved into one single folder which uses the slug of the entry that is part of the primary site (siteId(1)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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