4

Whats the best way to associate custom data to sitecore languages?

Imagine, if i need to associate API Key to each language.

  • Add new field called APIKey in /sitecore/templates/System/Language template.
  • Create new template with APIKey field and add that as base template to /sitecore/templates/System/Language
  • Create new template (SiteSettings) with APIKey, and create an item based on that template and associate content to each language to that item.

For me, first two approaches seems risky on upgrade. Third approach seems misleading

Is there any better way?

2
  • 1
    Why does the third approach seem misleading to you?
    – Koen Heye
    Feb 14 '17 at 19:46
  • 1
    You could create sitecore site definitions for each language, and add a custom attribute to the definition, that can be accessed through Sitecore.Context.Site[properties] Feb 14 '17 at 19:56
3

The third options seems the best to me. Just create a simple template with 1 field APIKey, not shared off course.
And for each language, add a version and set the APIKey to your unique value.

On a sidenote, the Helix documentation contains information about how to manage your configurations and settings. It is not always recommended to put everything in .config files nor have every single setting in Sitecore. http://helix.sitecore.net/principles/configuration/strategy.html

3

Agreed - the first 2 approaches are risky because you are changing core Sitecore templates and in upgrades you could lose those changes easily.

One option would be to create a template with a field for API Key and a droplink sourced to the languages to select the language.

LanguageApiLink
    - Data
        - Api Key (Single-line Text)
        - Language (droplink)

Then you can use that to link a language to an API key. No core templates altered, nice and simple to setup.

0

Since we are talking about language items, another option you could take, which is similar to Richard's response, is to create a very basic item that just stores the Api Key information.

ApiLink
    - Data
        - ApiKey (Single-line Text)

Then you can have different language versions of the same item, and as long as that field ApiKey isn't a shared field, you can vary the data in it per the language version of the item. Which option you choose depends on what your specific needs are.

But you should always avoid making changes to Sitecore items such as the Language items.

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.