I’m working on a basic sidebar panel plugin that should react depending on the active locale the user is editing.
Actually, I would like to create buttons depending on the active locale.
Regarding the documentation, the locale value should be available via ctx.locale but console.logging it gives me a undefined response:
Maybe I’m doing something wrong … Could you please tell me if I can retrieve this value ?
The related question, if it’s a yes, is this value reactive, meaning, when the user switch to another locale, is the value changing ?
My plugin is almost finished !
Thanks to your help on Slack, I could find the solution. ctx.locale was available in renderItemFormSidebarPanel method, not in itemFormSidebarPanels.
Anyway, got a last question.
Is there a way to get itemStatus for the current locale?
As far as I could see, ctx.itemStatus returns a string where possible values are new | draft | updated | published.
Let imagine I have 2 locales for a record, the 1st one is published, the second is not. How could I get the per-locale itemStatus ?
Thanks for your help.
PS: My plugin is quite simple, it’s a sidebar links, but … localized sidebar links, meaning that you can declare in the config, per model-record, depending on the locale of the record, allowing you for example to declare different published or draft URL depending of the record locale.
Our UI doesn’t do the best job of communicating this (sorry), but in DatoCMS, localizations are applied to specific fields, but publication status is tied to records. If you have a record with a “title” field in English & Italian, for example:
If you add a English title and save and publish it, the record status will be published
You add an Italian title and hit save. The record status is updated, and this applies to the whole record, not just any one field or locale.
You then publish the changes and the whole record becomes published.
Actually, I don’t need it at field level, but at locale level.
what I want to achieve is to print a “View Live version” button only if the record is published … but in the current local.
itemStatus property does not allow that.
Yes, sorry, that’s not easy to do right now without a manual diffing. In our current model, you can edit several fields across several locales and save it all as one version. The publication status is record-level, not field-level.
You can make a feature request for it here, but it would be a pretty huge backward-incompatible change, so it would be difficult to implement