1

I have a situation where I wish to automatically set entry title based on locale entry was created in. This is what I use for title:

{{ object.locale == "jp" ? "Japanese title" : "English title"}}

This works fine but when I create an entry in Japanese locale and open it in English locale and resave it the title changes to "English title" and that's not what I want, I wish to preserve the original title. Is that possible somehow?

0

Completely untested, but something like this should work:

{{ !object.id ? (object.locale == "jp" ? "Japanese title" : "English title") : object.title) }}

Basically only run your logic if the entry doesn't have an ID yet (which new entries won't until they are saved).

  • This totally failed, but gave me a good clue, thanks – Mato Dec 21 '17 at 15:07
-1

Thanks to Brad's help this is what worked:

{{ object.title ? object.title : (object.locale == "jp" ? "Japanese title" : "English title ") }}

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.