In V7 it was save to use the constructor of modelsbuilder to set a property.
In V8 this is not ok when dealing with variant properties.
When NuCache is reloaded it will hit the constructor with the backoffice language and when that doesn't exist it breaks NuCache and the views will show the default language.
When you get content.Label, you get content.Value("label") ie the value of the "label" property, for the current, ambient culture.
Therefore, when rendering a view, you get the value in the correct culture. If you render the same view with two different cultures, you get two different values.
However, outside a view, you get... the value corresponding to whatever is the current culture, and if you capture that value, eg
var label = content.Label;
the label variable contains the value for that current culture. And will not change. So, as a rule of thumb: do not capture things that are contextual. If you want to capture something, here, capture productOverview and then get its Label property when needed.
Another way to put it is this: a document is a "whole" with all its cultures, it is never "the english document". You cannot get "the german version of a document". Getting ancestors... gives you the ancestor documents. And the values of their properties depends on the current culture, not on the document itself.
AncestorsOrSelf<T>() returns wrong culture
In a site where the structure looks like this
-Product overview --Product category ---Product
In v7 if I needed a label from the productoverview to be shown for a property of a grandchild I could do something like this:
In V8 when I do the same in the culture en-US it returns the value of the default variant which is the nl-NL variant.
I just can't find a way to get the culture right
Ok, for future reference.
In V7 it was save to use the constructor of modelsbuilder to set a property. In V8 this is not ok when dealing with variant properties.
When NuCache is reloaded it will hit the constructor with the backoffice language and when that doesn't exist it breaks NuCache and the views will show the default language.
When you get
content.Label
, you getcontent.Value("label")
ie the value of the "label" property, for the current, ambient culture.Therefore, when rendering a view, you get the value in the correct culture. If you render the same view with two different cultures, you get two different values.
However, outside a view, you get... the value corresponding to whatever is the current culture, and if you capture that value, eg
the
label
variable contains the value for that current culture. And will not change. So, as a rule of thumb: do not capture things that are contextual. If you want to capture something, here, captureproductOverview
and then get itsLabel
property when needed.Another way to put it is this: a document is a "whole" with all its cultures, it is never "the english document". You cannot get "the german version of a document". Getting ancestors... gives you the ancestor documents. And the values of their properties depends on the current culture, not on the document itself.
Is this making more sense?
is working on a reply...