4

Sorry if this question already exists, haven't seen it before.

My dilemma is that I have certain field values, which could theoretically be any field type (general link, single-line text, etc.) which need to be different for different environments/publishing targets that exist within the same Sitecore instance.

In the past, we've dealt with this through configuration files which differ on the actual servers, but I'm wondering if there's a better way to handle this so they can be updated on the fly within sitecore (things like GTM keys, etc that may differ between environments).

The only thing I can think of is publishing to each individual environment separately and changing the values in sitecore for each, but this isn't really a sustainable solution since each environment would need to be republished each time there was a change to any of them.

Has anyone dealt with something like this before? How did you solve this issue?

Thanks!

3 Answers 3

3

The best approach is to used configuration file. You can easily deploy the configuration files to the required environment.

Doing this in Sitecore is typically very difficult and there is no OOTB feature for this. You'll require to manually set the value on each environment which is error prone and also time consuming in the sense that you need to go on each environment and update the value.

So, best approach is to use configuration file. For example, you may have separate files for UAT, Prod CM and CD. But the only drawback here is that it requires deployment.

1

I would create multiple items for your settings. You can use different approaches, I'll explain some that come to mind - all using multiple items:

  • add the environment as a field to the setting(s) item and adapt your code to check for the current environment when looking for settings
  • use the environment in the name of the setting(s) item and adapt your code to check for the current environment when looking for settings (if you have multiple setting(s) items, you could alter this approach a bit and use a folder)
  • use publish restrictions to publish the setting(s) item to the correct publishing target
  • a combination of the above

As you see, by using multiple items you have several options. Just make sure your solution stays user friendly for the editors: you should have an easy overview of all data for all environment when editing in the master database.

1

I have not seen such a scenario before (different items per publishing target?), and would probably try to stick to configuration files, but I'll take a stab at one solution:

Can you access the items via path? If so, you could theoretically:

  • Create an item for each environment
  • Give them all the same name
  • Use Display Name to distinguish them
  • Use publishing restrictions to enforce which item publishes to what target

Environment Items

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.