Setting __Renderings field not shared in Sitecore

2019-03-28 12:57发布

问题:

Does anyone have experience in setting the __Renderings field in Sitecore to not be shared? We are building a multi site-multi language solution and would need the (sub)layouts to be different in different languages. For example, the English language site could have a sublayout that the Swedish version of the same item does not have and all presentation components does not always have the same data source for different languages.

A somewhat easy solution to this would be to simply uncheck "shared" on __Renderings field in the /sitecore/templates/System/Templates/Sections/Layout template, but does this have any other consequences? Or is there a better way to handle this requirement?

回答1:

My own preference when needing to swap around visual elements based on something like language, country of origin, etc. is to use Sitecore's personalization rules editing to swap data sources and alter the presentation in that manner. It doesn't involve changing Sitecore's default behaviour and allows you to tap into built-in Sitecore functionality.

If your different 'sublayouts' are actually just the datasources being pulled in by various personalization rules, you can configure all of this with OMS/DMS and rely on the Sitecore engine to present the components you need given the current state. For performance, going with the most recent version of DMS is probably best (I believe 6.5 Update 5 is now the recommended release).



回答2:

Modifying Sitecore's default behavior in this way is usually not a good idea. It's not transparent for others people that might work with the system in the future and it could lead to unexpected results.

Imo, it's better to make a switch inside the (sub)layouts so it loads different files based on the current language.

As for the consequence. It will work as you expect when you make the _Renderings field unshared. You will be able to set different presentation details for each language version. The consequence is that you must now set it for each language version... so it will be less easy to manage.



回答3:

I would instead use the the Devices of sitecore. For each language you can define a Site and each site can have their own Device. This will work out-of-the-box if you have one domain name forr each language (www.site.com, www.site.de, www.site.fr etc...)

If you have one site (one host name) for all languages, you can switch the devices with a httpRequestBegin pipeline processor.

This article, http://briancaos.wordpress.com/2012/04/12/identifying-mobile-devices-in-sitecore/, describes how to identify mobile devices. It is not hard to rewrite the logic to switch devices depending on the language.

When you have defined different devices for each language you simply place the renderings on the device matching your language. And you still have the possibility of a fallback device for all those pages where all renderings are the same.

Modifying the Sitecore default behaviour might work for now, but using and extending the Sitecore platform is a better way forward.



回答4:

We have indeed done this, and for the most part there are few side effects. In fact, it's the only way you are going to get workflow on __Renderings changes. We combine it with Partial Language Fallback so that languages can inherit the value from English. However be careful, as if an item is cloned, it will always pull its default value from the clone first, rather than standard values / fallback.